Here's a checklist guide to debug not running cronjobs:
ps ax | grep cron
and look for cron.service cron start
or service cron restart
* * * * * /bin/echo "cron works" >> /tmp/file
/tmp
which does not currently exist should always be writable.2>&1
to include standard error as well as standard output, or separately output standard error to another file with 2>>/tmp/errors
/var/log/cron.log
or /var/log/messages
for errors.grep CRON /var/log/syslog
/var/log/cron
chmod +x /var/www/app/cron/do-stuff.php
30 1 * * * command > /dev/null 2>&1
>/dev/null 2>&1
altogether; or perhaps redirect to a file in a location where you have write access: >>cron.out 2>&1
will append standard output and standard error to cron.out
in the invoking user's home directory./etc/default/cron
EXTRA_OPTS="-L 2"
service cron restart
tail -f /var/log/syslog
to see the scripts executed/etc/rsyslog.d/50-default.conf
cron.crit /var/log/cron.log
sudo /etc/init.d/rsyslog reload
/var/log/cron.log
and look for detailed error output# Minute Hour Day of Month Month Day of Week User Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
0 2 * * * root /usr/bin/find
This syntax is only correct for the root
user. Regular user crontab
syntax doesn't have the User field (regular users aren't allowed to run code as any other user);
# Minute Hour Day of Month Month Day of Week Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
0 2 * * * /usr/bin/find
crontab -l
crontab -e
, for a specific user: crontab -e -u agentsmith
crontab -r