Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I used to have a crontab that ran like this

* * * * * /usr/bin/php /var/www/vhosts/default/htdocs/agent/time_keeper.php > /dev/null 2>&1

It worked fine. Now I moved that php script to a new directory and I now have the cron run like this

* * * * * /usr/bin/php /var/www/vhosts/default/htdocs/agent/php/time_keeper.php > /dev/null 2>&1

The new cron does not work. The file is there. I can run it fine from my browser. When I move the file back to its first directory and use the old cron, it works.

What is going on here?

share|improve this question

migrated from stackoverflow.com Dec 17 '12 at 20:32

This question came from our site for professional and enthusiast programmers.

    
are you getting some sort of error? –  Ibu Dec 17 '12 at 17:28
1  
did you use crontab -e to edit the crontab? –  fvu Dec 17 '12 at 17:29
    
What happens if you run the exact same command /usr/bin/php /var/www/vhosts/default/htdocs/agent/php/time_keeper.php from the console (and not from the browser)? –  fiskfisk Dec 17 '12 at 17:31
    
It is possible that your PHP file time_keeper is failing due to an include etc?? Have you looked at your logs? –  Zak Dec 17 '12 at 17:31
    
I used crontab -e. When I execute the script from shell it works correctly. The time_keeper script works fine. I am getting no errors. –  SofianeM Dec 17 '12 at 17:46
show 1 more comment

1 Answer

You may need to install your crontab - assuming you saved that line in a file called myfile.conf:

$ crontab myfile.conf

Note that this will overwrite all existing crontab entries.

share|improve this answer
    
I don't understand. What am I doing here? –  SofianeM Dec 17 '12 at 17:52
    
Crontab basically has a 'file' containing the jobs it has to run at which interval, for each user. You can update it by installing it (as above) or by editing the version crontab is running (by the -e flag). Following the comment thread above - do you have the crontab running under a different user? If so, crontab is still running the old command under a different user, and you've put a new task for it with the updated command under your user. –  webmage Dec 18 '12 at 9:15
add comment

Your Answer

 
discard

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