I'm trying to redirect STDOUT and STDERR with
&>> in my cron job, but I'm not seeing anything in the log file. The file is being created on the first run, but no OUT or ERR.
When I run a command with the
&>> redirect directly, it works as expected.
I can successfully redirect output with
... >> /tmp/log 2>&1, but according to this GNU page (3.6.5), these two approaches are equivalent, so I'm not sure why the first approach isn't working.
Any ideas what I'm missing here?
# # test.bash # echo "OUT" ecko "ERR"
# # crontab # * * * * * /bin/bash /root/test.bash &>> /tmp/test_log_1 # NOT WORKING * * * * * /bin/bash /root/test.bash >> /tmp/test_log_2 2>&1 # WORKING
# # using redirect directly works as expected # $ /bin/bash /root/test.bash &>> /tmp/test_log_3 $ /bin/bash /root/test.bash &>> /tmp/test_log_3 $ cat /tmp/test_log_3 OUT /root/test.bash: line 2: ecko: command not found OUT /root/test.bash: line 2: ecko: command not found
- Ubuntu 20.04.4 LTS
- Bash 5.0.17
- Cron 3.0pl1-136ubuntu1