Can a PHP script call a webpage like cron?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
John Rowe
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2003 7:53 pm

Can a PHP script call a webpage like cron?

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

why not require() your second page at the bottom of your first?
John Rowe
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2003 7:53 pm

Post 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
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Try sleep() for the delay.
phpmyborder
Forum Newbie
Posts: 2
Joined: Tue Dec 06, 2005 11:15 am
Location: Norway

Post by phpmyborder »

beware... the default timelimit is 30 seconds, so your script may timeout if you dont use set_time_limit()...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :)
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

just use exec() and make it a shell script, so they are truly seperate
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post 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. :)
Post Reply