cron jobs - how to run a simple php script

adentone

Registered
Feb 17, 2005
3
0
151
Spokane Valley, WA
I am trying to get a cron job to run a simple php script using the "standard" cron job method (non-expert).

I am not sure what to execute the script with...
lynx -dump www.mysite.com/folder/simplescript.php
is what I have tried, but it doesn't want to work

I tried just put in the relative and absolute path to the file,
but this doesn't seem to work, either

I do not need any output, I just need to manipulate a db and send an email depending on settings in the db.

Help!
Thanks!
 

sparek-3

Well-Known Member
Aug 10, 2002
1,983
218
343
cPanel Access Level
Root Administrator
Does running

php -f /home/your_username/public_html/script.php

give any errors? That would be the ideal way of running the script, as it would not spawn an apache instance.
 

DigitalN

Well-Known Member
Sep 23, 2004
420
1
168
Try the following, 'php' may not be in the users path for that cron job.

0 1 * * * /usr/bin/php -q /home/your_username/public_html/script.php

Running

# /usr/bin/php -q /home/your_username/public_html/script.php

From command line will do the same as the cron job would do, as has been mentioned.
 

adentone

Registered
Feb 17, 2005
3
0
151
Spokane Valley, WA
php -f -q /home/your_username/public_html/script.php
seemed to work great!!
thanks for your help!!


DigitalN said:
Try the following, 'php' may not be in the users path for that cron job.

0 1 * * * /usr/bin/php -q /home/your_username/public_html/script.php

Running

# /usr/bin/php -q
From command line will do the same as the cron job would do, as has been mentioned.
 

spaceman

Well-Known Member
Mar 25, 2002
509
5
318
fyi:

man php

"If none of -r or -f is present but a single parameter is given then this parameter is taken as the filename to parse and execute (same as with -f). If no parameter is present then the standard input is read and executed."

i.e. you don't have to specify -f

... but I also have a question: I've seen php -q in use, but can't see what the -q option does. Any takers?

Thanks