1

I am running Ubuntu 12.04 with Apache module. I opened crontab by executing vi /etc/crontab

It says on the top that unlike any other crontab you don't have to run the 'crontab' command to install the new version. So I don't have to run crontab crontab? Even if I am trying to execute it I receive the error

crontab: No such file or directory

I added this to the crontab file (there are 4 default jobs there):

*/1 * * * * root http://www.mywebsite.com/crondemo.php

This file should send me a mail every minute. The script itself works fine, but the job never runs and I never get a mail.

1

A crontab entry must be an executable shell command. A URL is not an executable shell command. Try */1 * * * * root wget -q -O- http://www.mywebsite.com/crondemo.php instead. wget is a command that fetches a URL. -q tells wget to not print progress, and -O- tells it to output the fetched URL to stdout, which cron will then email.

If you want to receive emails from cron, make sure you set MAILTO correctly above the relevant job in your crontab, and make sure that your system MTA works. You can use the mail command to test this.

The contents of /var/log/syslog may also help you diagnose cron problems, since cron will log jog attempts there even if it can't email you (provided that your crontab is installed and correctly provides a job schedule).

Finally, the comment is correct. As an exception, changes to /etc/crontab are picked up automatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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