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'm trying to run a scheduled task on my shared Linux server using the crontab via Terminal on my Mac.

I can login to my ssh OK, and can view directories etc with ease.

I try and create/edit my crontab by using...

crontab -e

But i get the response

no crontab for [username] - using an empty one

So trying to then add my line to set my schedule up, and Terminal just doesn't seem to respond.

10 * * * * /home/username/www/myphpfile.php

Any clues what on earth I'm doing wrong? Or a link to a clear step-by-step tutorial?

I have checked with the webhost that this is supported, it's just undocumented!

All I want to do is run a php script every so often through the day (to check for updates to an XML file).

share|improve this question

migrated from Feb 15 '10 at 22:52

This question came from our site for professional and enthusiast programmers.

What do you mean, "Terminal just doesn't seem to respond"? Are you not presented with a text editor in which to specify your cron jobs? – FRKT Feb 15 '10 at 22:37

I'm betting the $EDITOR variable is set to vi(m).

If you press i to go to interactive mode are you then able to enter your crontab?

If so after you are done entering your cron entry, press escape then type :wq<enter> to save your changes.

Also, learning vi(m) is a good thing check out: for a beginner's tutorial.

share|improve this answer
great, i'll give this a try. it's not something i ever thought i'd use, so it's completely alien to me. I'll let you know how I get on – user34990 Feb 16 '10 at 9:13

try to set EDITOR environment variable, for example doing:

export EDITOR
share|improve this answer
While Zepher's correct that it's the default vi editor Shuvalov is spot on about changing the default editor. Try his suggestion in one line: export EDITOR=nano – Patrick R Feb 16 '10 at 1:04

Your mistake is that you don't call the PHP interpreter at all. Use this instead:

// Assuming your PHP executable resides under /usr/local/php5/bin
10 * * * * /usr/local/php5/bin/php /home/username/www/myphpfile.php

Good luck.

share|improve this answer
Your mistake is that you forget about the #! line. Use it and chmod +x instead. – grawity Feb 16 '10 at 9:29

Looks like one of two possibilities.
1. There is a problem with cron
2. There is a problem with php from the command line

  1. Try a simpler command like touch or copy to make sure the cron is working.

  2. Is the php command line interface installed on your hosting service? If so, then maybe you need to review your code to use the CLI effectively

Hope this helps

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.