Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am on Ubuntu server and would like to send an email to myself every 10 minutes (as a test).

The code for that is in this file:

/var/www/cron-test.php

To set up the cron I typed:

crontab -e

and added this line to the bottom of the file using nano editor:

### email me every 10 min.
*/10 * * * * /var/www/cron-test.php

But that script is not running every 10 minutes. I only recieve the email if I load the PHP script directly in my browser. The cron doesn't seem to be executing at all.

What am I doing wrong?

Also this is my first time setting up a cron so putting the cron script in my www folder is probably not a good idea, should I put it elsewhere? If so where?

Also is there a cron error log? Where all failed crons can be seen?

share|improve this question
1  
You need to run it through PHP of course, php-files are not executable. –  Bobby Jun 10 '12 at 16:39
    
@Bobby I can run the script by navigating to /var/www and typing "php cron-test.php". How should I modify the cron command to tell it to run the script using the "php" command. Just by adding php before the path to the script? –  JakeRow123 Jun 10 '12 at 16:42
    
@Bobby Ahh it works now. Just had to add php before the script path. Thanks for bringing it to my attention. If you post that as an answer I will accept. –  JakeRow123 Jun 10 '12 at 16:46

1 Answer 1

up vote 2 down vote accepted

Just stating the obvious:

*/10 * * * * php /var/www/cron-test.php

You might also need to write the full path to your php interpreter.

share|improve this answer

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.