Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've put two files in the /etc/cron.d/ directory:

The first makes a new post everyday at 12:00AM:

0 0 * * * php /var/www/site1/helper post:make

The second updates the latest post every 10 minutes

10 * * * * php /var/www/site1/helper post:update

Do I have to do something else for this job to run based on the time (eg. every 10 minutes) or do I have to do crontab job1 and crontab job2?

EDIT: I also installed cronie.

share|improve this question
up vote 13 down vote accepted

Putting files in cron.d is enough. However, your last entry should be:

*/10 * * * * php /var/www/site1/helper post:update

Otherwise it runs once an hour, at the 10th minute.

share|improve this answer
Oh wow thank you for correcting :) – Michelle Jun 14 '12 at 10:03
And as mentioned below, add a user. I didn't look closely enough and thought php was your user :) – Halfgaar Jun 15 '12 at 12:24

Also, add

> /dev/null 2>&1

at the end (after the command) so the cron won't spam you with outputs :)

share|improve this answer
how will it spam me with outputs? thanks. – Michelle Jun 14 '12 at 10:30
The output of cron jobs goes to the mail box of the user it was running as by default. If you haven't configured your mail server or added something to /etc/aliases, these will end up in /var/spool/mail/<username>. Eventually, they will fill your filesystem... which is bad. – Ladadadada Jun 14 '12 at 10:34
Exactly :) It is very interesting when you create a 1 or 2 minute crons and you open your mailbox after 2 days :) – mangia Jun 14 '12 at 10:36
Oh I didn't know that, It currently has 280 lines. Thank you! – Michelle Jun 14 '12 at 10:45
Only put that on the end of the line after you have tested it to ensure it's working correctly, otherwise it won't tell you if there is a problem. – John Gardeniers Jun 14 '12 at 16:01

The crontabs in /etc/cron.d/ require a username in the 6th field, as does /etc/crontab. User-based crontabs in /var/spool/crontabs/ and via crontab -e do not have a username field.

Halfgaar's answer about the timing of the one that runs every 10 minutes is also correct.

Currently, these cron jobs execute /var/www/site1/helper as the php user rather than executing /usr/bin/php and passing it the arguments /var/www/site1/helper post:make. This will work if your have a php user, the file is executable and has an appropriate shebang. (i.e #!/usr/bin/php as the first line.) Otherwise, it will log an error in /var/log/cron/log.

The example below runs them as the httpd user and has an explicit path to the PHP executable. You should choose an appropriate user.

0     0 * * *  httpd /usr/bin/php /var/www/site1/helper post:make
*/10  * * * *  httpd /usr/bin/php /var/www/site1/helper post:update
share|improve this answer
can I run it as a root user instead? Oh and Yeah I checked var/log/cron and it has a line about invalid username. – Michelle Jun 14 '12 at 10:31
You certainly can. Choosing a different user is part of the principle of least privilege. If it doesn't require root, don't use root. – Ladadadada Jun 14 '12 at 10:32
Thank you Ladada – Michelle Jun 14 '12 at 10:33


10 * * * * php /var/www/site1/helper post:update

Will not run every 10 minutes, it will run at minute 10 of every hour (00:10, 01:10, ...).

This will run every 10 minutes:

*/10 * * * * php /var/www/site1/helper post:update
share|improve this answer
thank you so much @faker – Michelle Jun 14 '12 at 10:04

Your Answer


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.