Running PHP Scripts on CRON

DarkFenix

New member
Joined
Oct 25, 2003
Messages
2
i can't running php scripts on cron... can anyone help me with this??


i try this:


Minute 0,5,10,15,20,25,30,35,40,50,55
Hour *
Day of Month *
Month *
Day of Week *

and the command:

/home/dktech/domains/mydomain/public_html/script.php

or

php /home/dktech/domains/mydomain/public_html/script.php

doesn't happen anythink... why?


tks for any help please :|
 

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
9,070
Hello,

php scripts arn't executable as they are unless they either have:

#!/usr/local/bin/php

at the top of the file, or you have the cron command set as:

/usr/local/bin/php /home/dktech/domains/mydomain/public_html/script.php

John
 

bob_gps

New member
Joined
Oct 18, 2006
Messages
1
After starting by cron my php script I receive following message:
"Warning: fopen(/home/name/domains/site.com/public_html/folder/file):
failed to open stream: Permission denied"
If I run this script from browser it works.
File attributes 666. Where I'm wrong?
 

sullise

Verified User
Joined
Mar 4, 2004
Messages
519
Look in your php.ini and see if you have url_fopen disabled.
 

redesb

Verified User
Joined
May 10, 2004
Messages
207
Location
Spain
If you use 'wget' is better to add the '-O -' option for don't get writed the downloaded file to the disk, only to 'stdout' and if your file is in one protected dir you can add the options '--http-user=USERNAME --http-password=PASS', see bellow:
Code:
wget -O - --http-user=USERNAME --http-password=PASS [url]http://www.example.com/protected/script.php[/url] > /dev/null 2>&1
But as security option I have 'wget' disabled to all users except root, and I prefer to use 'lynx' (more secure) like this:
Code:
lynx -dump -auth=ID:PASS [url]http://www.example.com/protected/script.php[/url] > /dev/null 2>&1
The '-dump' option is for get the output on 'stdout' and the '-auth=ID:pASS' because I have the script in one protected dir, omit if not your case.
 
Top