WebFaction
Community site: login faq

Hi, I'm trying to set up a cron job to run a PHP script hourly. This is my crontab entry:

0 */1 * * * $HOME/webapps/path/to/cron/cron.php

What am I doing wrong? I have also tried in the format:

0 */1 * * * /home/username/webapps/path/to/cron/cron.php

and still no luck. Can anyone help?

asked 19 Oct '11, 14:08

appltn
313
accept rate: 0%


You need to specify the PHP interpreter, like this:

0 /1 * * /usr/local/bin/php $HOME/webapps/path/to/cron/cron.php

I hope this helps!

permanent link

answered 19 Oct '11, 15:54

maryh
1.3k7
accept rate: 35%

Hi thanks for the response, but it still isn't working. This is what I have now:

*/1 * * * * /usr/local/bin/php $HOME/webapps/path/to/cron.php

(running once a minute whilst I'm debugging)

Have I got the syntax for the timing correct? Is it okay to use $HOME? Could there be something else wrong?

(23 Oct '11, 04:20) appltn

Yes, the syntax and the $HOME both are ok. Yes, something else could be wrong.

Can you execute the command without problems on the terminal?

If so, can you file a ticket at help.webfaction.com so we can look further?

(23 Oct '11, 04:43) neeravk

Aha!

It didn't occur to me that I could run it from the command line, but once I did the error messages let me track down the issue - my cron.php script was referencing a relative path which couldn't be found. Changed to an absolute path and it works.

Thanks for the help!

(23 Oct '11, 05:19) appltn
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×81
×50

question asked: 19 Oct '11, 14:08

question was seen: 7,423 times

last updated: 23 Oct '11, 05:19

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM