Page 1 of 1

Can a PHP script call a webpage like cron?

Posted: Mon Dec 05, 2005 11:20 pm
by John Rowe
Hello,

Sorry if this is a really dumb question, but I have a PHP script on my server. And using cron, I call this script throughout the day. I also have a second cron job setup to call a second script. The second script is setup to run three minutes after the first script. So it works like this...

cron1 calls http://domain.com/script1.php... then...
cron2 calls http://domain.com/script2.php...

Is it possible to put something inside script1.php that will call script2.php once script1.php is done processing? The reason I am wondering... is so that I only have to run 1 cron job instead of two.

Is this type of thing possible? Can one php script run... and then call another script just like a cron job?

Thanks for any help.

Kindly,
John

Posted: Mon Dec 05, 2005 11:33 pm
by Burrito
why not require() your second page at the bottom of your first?

Posted: Mon Dec 05, 2005 11:48 pm
by John Rowe
Thanks for the response.

I wasn't sure if that would work. As I know almost zero about PHP. :D

Also, I need about a three second delay between scripts. Might there be a way to do that before the 'require'?

Thanks again.

Kindly,
John

Posted: Tue Dec 06, 2005 12:18 am
by Buddha443556
Try sleep() for the delay.

Posted: Tue Dec 06, 2005 11:33 am
by phpmyborder
beware... the default timelimit is 30 seconds, so your script may timeout if you dont use set_time_limit()...

Posted: Tue Dec 06, 2005 11:46 am
by Chris Corbyn
phpmyborder wrote:beware... the default timelimit is 30 seconds, so your script may timeout if you dont use set_time_limit()...
You know what's interesting... I've never checked if the timeout waits while sleep() has been called... e.g. If you had a script with sleep(60) would it timeout or would it run for up to 90 seconds?

/must go and test :)

Posted: Tue Dec 06, 2005 12:48 pm
by josh
just use exec() and make it a shell script, so they are truly seperate

Posted: Tue Dec 06, 2005 1:00 pm
by AKA Panama Jack
d11wtq wrote:
phpmyborder wrote:beware... the default timelimit is 30 seconds, so your script may timeout if you dont use set_time_limit()...
You know what's interesting... I've never checked if the timeout waits while sleep() has been called... e.g. If you had a script with sleep(60) would it timeout or would it run for up to 90 seconds?

/must go and test :)
It will time out. The sleep time is included in the total execution time. :)