run php script continuously after closing browser from host

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
dpkdn
Forum Newbie
Posts: 3
Joined: Thu Feb 02, 2012 9:55 pm

run php script continuously after closing browser from host

Post by dpkdn »

I want to run a php script continuously even after browser is closed..... :?
actually i am inserting data into ms-sql database which happens on every 5 seconds ..
thats why i need help so that i can run that script forever even after i close browser and shutdown pc...
my script is located on a web host..under some domain.
I have used
ignore_user_abort(1); // run script in background
set_time_limit(0); and also (-1);
but then also it is running upto 30 to 40 seconds...
I dont know how to do this...


any help regarding to this is appriciated...
thanks in advance.........
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: run php script continuously after closing browser from h

Post by Eric! »

Basically you can't do this and I don't think you would want too. If you had 1000 users you'd end up with 1000 versions of the same script running and crash your server.

You can run a php script independently of a user via a cron job. You can just configure the cron job to run at whatever time interval you want and that will start up your script automatically.
Post Reply