crontab not running at specific time, but runs every min

7,203

Solution 1

change UTC from yes to no in /etc/default/rcS. It works now.

Solution 2

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)
  • 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
  • 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 (see man 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.

Solution 3

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
Share:
7,203

Related videos on Youtube

Bastien
Author by

Bastien

Updated on September 17, 2022

Comments

  • Bastien
    Bastien over 1 year

    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.

    • katriel
      katriel over 13 years
      Have you checked your log file? cron usually writes to /var/log/messages
    • Bastien
      Bastien over 13 years
      I found cron entries in syslog and realized the timestamp is off by 5 hours. I thought cron jobs went by the server time?
  • Bastien
    Bastien over 13 years
    Thanks for your reply. I found out the date in my syslog is different than the date I get when I run "date". What gives?
  • icyrock.com
    icyrock.com over 13 years
    @Bastien I see you found a solution yourself - tricky one, I might say...
  • womble
    womble about 4 years
    Can you expand on why this will solve the problem described?