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 have a folder in my live directory (/var/www), called cron. How do I configure the server to find this directory, in order to execute the files using a cron.

I need to run certain scripts at different intervals. e.g. 2-3 Files everyday, and 1-2 files every Wednesday.

What would I need to put in the crontab in order do the above? I've attempted to add * * * * * /var/www/email.php as a text, which should send me an email every minutes, but nothing comes through.

Am I doing something wrong?

share|improve this question
Have you tried to see /var/log/syslog to check for error messages ? Do you have access to the server as root ? Maybe the cron service is not running... – Feiticeir0 Aug 7 '11 at 15:46
It says it failed with exit status 2? – user826855 Aug 7 '11 at 16:14
exit status 2 usually is ENOENT i.e. 'no such file or directory'. Cron probably wasn't able to read its file. – bitwelder Aug 7 '11 at 19:02

try it this way:

* * * * * php -q /var/www/email.php

also make sure the file is executable as the user you run the cronjob as

share|improve this answer
Do I put that code in the crontab file? How do I check the file is executable as the user I am running the cronjob as? – user826855 Aug 7 '11 at 16:16
@user826855: If you have to ask something as basic as that then you shouldn't be doing any of this. – Iain Aug 7 '11 at 16:20
edited code to show it as an example cron line based on your info provided, but plus 1 on Iain, be very careful if you dont know what your doing – anthonysomerset Aug 7 '11 at 16:21
@Iain Everybody has to start somewhere, plus I'm on a testing server, so it mistakes don't really matter. – user826855 Aug 7 '11 at 20:22
@user826855: faq – Iain Aug 7 '11 at 20:37

I don't think you can change the location of a users crontab file. They are usually located /var/spool/cron/crontabs/<username> Why do you want to place a crontab in /var/www/cron ?

Does email.php contain a shebang line at the top #!/usr/bin/php (or similar) if is doesn't then you should add one.

If email.php does have a shebang ensure that it is executable by the user who is running it.

Is cron running ?

ps -ef | grep cron | grep -v grep
root      4148     1  0 Aug04 ?        00:00:00 crond

if not start it.

share|improve this answer
I don't want to place a crontab in "/var/www" I just want to execute some files as a cron that are located in "/var/www". What does "#!/usr/bin/php" do? – user826855 Aug 7 '11 at 16:36

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.