Crontab no error but doesn't execute script
Solution 1
Have you checked that the command line has a linefeed/CR at the end of the line? I struggled for hours trying to find a reason for non-executing php script on cron when I simply hadn't pressed enter at the end of the line when I edited the cron jobs with crontab -e :-)
Solution 2
Have you checked /var/log/cron
for clues?
Solution 3
* * * * * /bin/sh /home/myuser/shellscript.sh
or
* * * * * /bin/bash /home/myuser/shellscript.sh
worked for me in Macosx 10.6 as rootuser
Solution 4
Have you tried
* * * * * /bin/sh /home/myuser/shellscript.sh > /home/myuser/logfile
Solution 5
cron sends any errors via email to owner of the crontab file (often "root" so you might check that account's email). To have any errors mailed to "crontabOnFreebsd" put:
MAILTO=crontabOnFreebsd
in your crontab (near the top).
For more info issue this command:
man 5 crontab
Admin
Updated on June 07, 2022Comments
-
Admin almost 2 years
I'm trying to execute a shell script from cron on Freebsd.
To test whether
crontab
is working at all, I wrote the line* * * * * echo "Hello" > /home/myuser/logile
and it work fine.
But when trying to execute any script it doesn't do anything, not even an error. (In the script I tried to run is just the same echo command) Below is the output of
crontab -l
:SHELL=/bin/sh PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin HOME=/home/myuser MAILTO=myuser * * * * * /home/myuser/shellscript.sh > /home/myuser/logfile
Why is the script not getting executed, although
crontab
is obviously running? Permission for all files are set torwxr-xr-x
.