I realise that there are plenty of cron questions on the site and I've spent the last hour searching for a solution but haven't been able to find one. Essentially the cron job does execute, but it doesn't seem to execute or at least output the output to a file that I specify.
I can see that cron is running:
josh@lin-ldn-cen:~$ pgrep cron 734
The cron job executes successfully, as seen in my /var/log/cron file:
Sep 26 08:34:01 lin-ldn-cen CROND: (josh) CMD (/home/josh/test_script.sh > /home/josh/cron_logs/test.log)
I've used absolute paths as well as setting the PATH in my crontab file. I've included a newline at the end of my crontab file:
josh@lin-ldn-cen:~$ crontab -l SHELL=/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin 0 */6 * * * /home/josh/youtube-downloads/download_djdj.sh > /home/josh/cron_logs/cron_download_djdj.log */5 * * * * /home/josh/youtube-downloads/download_djdj.sh 2>&1 /home/josh/cron_logs/cron_download_djdj.log * * * * * /home/josh/test_script.sh > /home/josh/cron_logs/test.log
(Having the path at the top hasn't made any difference at all to the execution of my script)
test_script.sh is incredibly simple, and I used absolute paths there too - here it is:
josh@lin-ldn-cen:~$ cat test_script.sh #!/bin/bash/ /usr/bin/echo Hello world
I've also tried several other things - including a
. before my script in the crontab file, using 2>&1 to output errors, double checked paths, double checked that the .sh file is executable with chmod +x test_script.sh, included both sh and bash before the command in my crontab file - none of this seems to work. All I'm expecting from this is to see 'Hello world' in /home/josh/cron_logs/test.log.