I've tried eliminating many of the common errors,
ensuring that the PATHs are available for cron
there is an endline at the end of crontab file
the timezone is set-up by:
cd /etc cp /usr/share/zoneinfo/Asia/Singapore /etc/localtime
date in bash, I get:
Tue Sep 17 15:14:30 SGT 2013
In order to check if cron is using the same time,
* * * * * date >> date.txt
is giving the same date output in date.txt.
This is the script I'm trying to execute:
#!/usr/bin/env bash echo data > /root/data.txt
crontab -e, the line below works,
* * * * * /bin/bash /root/event.sh >/tmp/debug.log 2>&1 15 * * * * /bin/bash /root/event.sh >/tmp/debug.log 2>&1
However, when I tried some other arguments, hoping it would run at 2.50pm:
50 14 * * * /bin/bash /root/event.sh >/tmp/debug.log 2>&1
50 14 * * * (cd /root ; ./event.sh >/tmp/debug.log 2>&1)
it will no longer work. Seems like there is a problem with my hour argument. Nothing could be found in the
/tmp/debug.log file either.
It turned out I have to restart the cron service after making changes to TZ.
* * * * * /bin/bash /root/event.sh >/tmp/debuge.log 2>&1
* * * * * dateand confirm that
dateshows the expected time. Note that setting the TZ environment variable from within the crontab might not affect the time zone as used by the cron daemon itself, but it will affect processes launched through cron, so if you set TZ in your crontab I'd suggest commenting it out temporarily and setting the time using the system clock's timezone (probably UTC if you are single-booting Linux, but may be local time) instead.