crontab not running at specific time, but runs every min
I want to run a cron job every day at 8:10pm.
10 20 * * * curl -s -o /dev/null http://www.example.com/blah.php
However, it doesn't work.
If I try to run it every minutes:
* * * * * curl -s -o /dev/null http://www.example.com/blah.php
It works fine. What gives?
The command "date" yields the correct time on my server.
Solution 1:
change UTC from yes to no in /etc/default/rcS. It works now.
Solution 2:
This answer helped me with the same situation. Restarting the cron service helped my server's cron service recognize the changes I made to the system's date.
https://stackoverflow.com/questions/34626135/crontab-linux-not-running-at-specific-time
sudo service rsyslog restart
sudo service cron restart or sudo service crond restart
Solution 3:
The above should be working just fine. Here's a list you can try:
- Try a different time - e.g. set it to run 5 minutes after now and see if it works
- Try a different user
- Or a different crontab (
/etc/crontab
or another user's crontab)
- Or a different crontab (
- Try a simpler command (e.g.
echo works > /tmp/cron-works
)- You can also just prepend the above to your curl (e.g.
echo works > /tmp/curl-works; curl ...
) or something along these lines - It's also good to add another cron entry at the same time which does echo and leave your curl in there as is
- You can also just prepend the above to your curl (e.g.
- Check the logs -
/var/log/syslog
should show it executing the commands and possible failures - Confirm your curl actually ran - how do you know whether it ran? I assume you are looking at the logs for
www.example.com
- if so, double-check the logs - Try special values such as
@houry
(seeman 5 crontab
for the complete list)
Also, how are you authenticating - if it's a network authentication, you may need to confirm this is working before any crontab executes.