Page 1 of 1

execute a php script without a cron job?

Posted: Thu Jan 25, 2007 10:59 am
by SmokyBarnable
I had a small php program that checked my email via cron job every 60 seconds. My isp just told me I can't do it that often. Is there any way to have a php script run forever on a server without a cron job?

Posted: Thu Jan 25, 2007 11:04 am
by feyd
How about setting it to a slower pace so that it doesn't upset your host?

Posted: Thu Jan 25, 2007 11:29 am
by John Cartwright

Code: Select all

set_time_limit(0);
ignore_user_abort(1);

while(1)
{
   // Yay I will never end unless you kill the process!! 
   
   //sleep sleep for 60 seconds
   sleep(60);
}
If your feeling adventurous. I'm not sure how this will affect your server performance though.. likely horribly.

Posted: Thu Jan 25, 2007 11:40 am
by Kieran Huggins
8O

Somewhere, a sysadmin is screaming "JCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRRRRRRRRT!!!!!!!"

Posted: Thu Jan 25, 2007 1:37 pm
by AKA Panama Jack
Download...

http://www.bitfolge.de/pseudocron-en.html

And then add...

something like this

Code: Select all

include ("pseudo-cron/pseudo-cron.inc.php");
to every page on your website.

But then again now that I think about it you are doing something really strange.

Why aren't you using an email client that checks your email every second instead of doing it on the server?

Posted: Thu Jan 25, 2007 2:01 pm
by SmokyBarnable
Why aren't you using an email client that checks your email every second instead of doing it on the server?
It just checks to see if any of my ebay auctions have any new sales and then sends an end of auction email to the bidder. I would do it with the above method but ebay limits the amount of api calls you can have per month. So parsing end of auction emails was the only way I could figure to trigger an api call.....but my isp didn't like it much.

Posted: Fri Jan 26, 2007 11:26 am
by AKA Panama Jack
SmokyBarnable wrote:
Why aren't you using an email client that checks your email every second instead of doing it on the server?
It just checks to see if any of my ebay auctions have any new sales and then sends an end of auction email to the bidder. I would do it with the above method but ebay limits the amount of api calls you can have per month. So parsing end of auction emails was the only way I could figure to trigger an api call.....but my isp didn't like it much.
Then why don't you just process them once every 30 minutes? That should be soon enough and most hosting companies that have limits on how often cron tasks can be run allow that.