Crontab – General Tips

Here are some very common crontab issues that users often have.

1. First, make sure that the command you are trying to use runs without error from the command line. If it doesn’t run from the command line it will not run from cron either.

2. Make sure you use the full path to all programs. The environment inside of crontab is different than the shell. You almost always need to give full paths to everything.

As an example, if you want to use wget :


*/30 * * * * wget http://my-domain.com/some_page.php

Use:

/usr/bin/wget http://my-domain.com/some_page.php

and not just

wget http://my-domain.com/some_page.php

The correct line would look like :

*/30 * * * * /usr/bin/wget http://my-domain.com/some_page.php

This also goes for all file path names. Make sure you give the full path such as :

/home/your_user_name/

3. You may also want to add:

MAILTO=your_email_address@your_domain.com

to the top of the crontab to make sure it is mailing you an errors that are generated. This will make it much easier to debug any problems you are having.

Leave a Reply

Your email address will not be published. Required fields are marked *