Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to run a cron job every day at 8:10pm.

10 20 * * * curl -s -o /dev/null http://www.domain.com/blah.php

however, it doesn't work.

If I try to run it every minutes:

* * * * * curl -s -o /dev/null http://www.domain.com/blah.php

it works fine. What gives?

The command "date" yields the correct time on my server.

share|improve this question
1  
Have you checked your log file? cron usually writes to /var/log/messages –  katriel Dec 19 '10 at 20:35
    
There is nothing regarding the cron job in messages.log –  Bastien Dec 19 '10 at 20:36
    
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 Dec 19 '10 at 20:44

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer

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.domain.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.

share|improve this answer
    
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? –  Bastien Dec 19 '10 at 20:48
    
@Bastien I see you found a solution yourself - tricky one, I might say... –  icyrock.com Dec 20 '10 at 1:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.