tags:

views:

368

answers:

3

Hey,

I want to call a php script every minute. My scriptruntime on my webserver is about 90 sec. I thought doing it with cronjobs but i have to pay for that service. Is there an other possibility?

Thanks a lot.

+3  A: 

Not really. You could have the script call itself 60 seconds after it completes. But if the script crashes, it won't restart.

Something like sleep(60*1000) to cause it to sleep for 60 and then just either call the page again, or start the script over at the top.

Malfist
PHP might timeout...
luiscubal
Well, cron is the accepted tool for this, anything else is a hack.
Malfist
hmmm... single point of failure... not good.
jldupont
`sleep(60*1000)` would put PHP to sleep for almost 17 hours!
Alix Axel
That's fine, Alex, the longer php sleeps the better this world gets.
Michael Krelin - hacker
+7  A: 

Use a script on Google AppEngine to "ping" yours (Scheduled Tasks to be more precise). It's free :-)

jldupont
could you please describe that with more precision :)?
rdesign
+1, original solution! =)
Alix Axel
@rdesign: create a Scheduled Task on GAE (it's a cron job that calls a script in your GAE project) and have the "cron script" issue an "HTTP GET" (or whatever) to your server. This would trigger the PHP script on your server.
jldupont
A: 

Try some online cron services. This is more or less the same jldupont suggested, though.

Depending on the php setup you might be able to launch your script with

php /wherever/yourscript.php </dev/null &>/dev/null

command line from inside php.

Michael Krelin - hacker