i want to write a PHP script that run at sever start up?

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
codeworks
Forum Newbie
Posts: 2
Joined: Sun Feb 14, 2010 2:44 pm

i want to write a PHP script that run at sever start up?

Post by codeworks »

Please i want to write a PHP script that will be accessing database at interval without human intervention. Once the script is uploaded to the web server, it should keep running until the server is shut down and when the server is up again the script should start running again.
Is this possible thanks
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Re: i want to write a PHP script that run at sever start up?

Post by infolock »

Yes, it is possible, but it is not possible with PHP alone. How you do this all depends on your server environment, ie: what server are you running (linux, windows, etc), what web server are you running (apache, iis, etc), what database server are you running (mysql, mssql, oracle, etc).

What you'll have to do is, for whatever server you are running, determine how each are started. Then, you'll have to figure out if there is a manner in which to load a script during server start, and server stop (or process start, process stop).

For linux, you could create a script that is run once you call apachectl start/stop, and then execute a PHP script from there. For IIS, you'd do a windows service. The scope and specs are for you to figure out from the vast knowledge google can give you. I hope this helps answer your question though.
Post Reply