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

This question already has an answer here:

I'm running a CentOS 5 server, and trying to schedule a job which runs a php file every day at the same time, I've added a new file to the directory


called get_files

The get_files file contains the following:

03 6 * * * php /var/www/html/get-info.php

However, the above job doesn't seem to get run. What am I doing wrong?

share|improve this question

marked as duplicate by Iain Apr 6 '13 at 17:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

That is an excellent canonical answer. It probably covers every cron-related question we've ever had here. – Ladadadada Apr 6 '13 at 17:55
@Ladadadada: It is now, the $original was full of $fail. – Iain Apr 7 '13 at 16:33
up vote 1 down vote accepted

you should use the full path to php, and use the -f switch

03 6 * * * /path/to/php -f /var/www/html/get-info.php
share|improve this answer

The cron jobs in /etc/cron.d/ (and also /etc/contab) have six parts before the command, not five. The first five are as you expect, the schedule. The sixth is the user the command should run as.

Cron files often have explicitly set variables such as SHELL and PATH which avoids requiring full paths to everything in the rest of the cron file.

03 6 * * * root php /var/www/html/get-info.php

Your original cron job would have been logging an error in /var/log/cron saying that it couldn't find the user "php".

share|improve this answer
+1, nice catch. – David Houde Apr 7 '13 at 5:51

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