Crontab is creating sequentially numbered, emtpy files in my directory (file.1, file.2, file.3 etc.)

Question:

I have the following crontab:

* * * * * /usr/bin/wget http://mydomain.com/ow_cron/run.php > /dev/null

It works but it leaves files called run.0, run.1, run.2, etc. in my home directory. I added :

> /dev/null 2>&1

to the crontab but it still does it. How can I make it stop?

Answer

Add the option:

–delete-after

and the annoying sequentially numbered files should stop.

An example:

* * * * * /usr/bin/wget --delete-after http://mydomain.com/ow_cron/run.php > /dev/null

My crontab has extra comments at the top that I did not add!

Question:

My crontab file has lines similiar to :

# DO NOT EDIT THIS FILE – edit the master and reinstall.
# (/tmp/crontab.31994 installed on Fri Apr 16 09:43:07 2004)
# (Cron version — $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)

at the top. I did not add these. How did they get there?

Answer:

Those lines are added automatically by the crontab system when you update your crontab. You can ignore them. They are comment lines and do not affect the running of your crontab.

Calling php in my cronjob doesn’t work?

Question:

I have a crontab line that calls php but it doesn’t work. I use:

5 0 * * * php -f /home/my_home_directory/www/script.php

What’s wrong?

Answer:

Change your call to php from:

php -f /home/my_home_directory/www/script.php

to

/usr/local/bin/php -f /home/my_home_directory/www/script.php

and it will work. Crontab requires the full path (/usr/local/bin/php) to the php binary.

If you need the php-cli version, call :

/usr/local/bin/php-cli

How can I control where output mail from my crontab is sent to?

Question:

I noticed that whatever e-mail is sent by cron it is stored in ~/Mailbox , is there a way to forward these mail to my POP account hosted on the same server?

Answer:

Yes, put the line:

MAILTO=your_email_address@your_domain.com

at the top of your crontab file. This will send all crontab output to that email address

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.

Do you offer atd service?

Question:

Is the command “at” available for me to use? When i issued an at command, i got the following message:

Can’t open /var/run/atd.pid to signal atd. No atd running?

Answer:

To keep servers running as fast as possible, we no longer offer atd service. While Atd is not a large drain on system resources we try to keep as few non-critical processes running as possible. We do offer crond. Cron can replicate (and goes beyond) most of atd’s functionality.

 

You can edit your crontab with the command :

crontab -e

from inside of ssh.

 

How do I use crontab?

We offer standard unix crontab. No special setup is required. All accounts have crontab enabled by default.

You can login via the shell and type:

crontab -e

to edit your crontab.

If you have your desired crontab commands in a text file, login to ssh and type :

crontab name_of_file.txt

and it will reset your crontab to use those commands.

Any standard tutorial on crontab will be applicable to our configuration.