473,471 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can i make a php program run like a service in the server?

kvijayhari
25 New Member
hi

I'm going to write a program that should be running all the time (24/7) in my server say like a service..

Whenever my server is running this program should be running and whenever i start/restart my machine the program should automatically start and run.

The program will be in php. How can i make this to run like a service?

So how can do this ?
Jul 28 '08 #1
13 5071
Stang02GT
1,208 Recognized Expert Top Contributor
Moving to PHP forum in hopes they will be able to guide you better
Jul 28 '08 #2
coolsti
310 Contributor
What do you mean by "running all the time"? That is going to chew up a lot of your CPU if you have a PHP script always doing something.

It sounds to me like you wish a PHP script to run repeatedly, say for example every minute or every 5 minutes or every 10 minutes, or once each hour or something like that. Is that what you want? If so, you can configure your PHP script to run in a standalone fashion (without a web server, or the PHP-CLI mode) and then set up a batch program to run your script at the regular intervals you desire. If you are working on a Linux machine, you would do this by setting up a cron job. Not sure what you do if you are using Windows.
Jul 28 '08 #3
kvijayhari
25 New Member
i'm going to use linux and i want that program to run all the like a service...

I'm sure about that, this program should be running all the time,this program has very important monitoring and queuing stuff. so it need to be running..

I thought of cron, but for example if the crontab itself fails, who will initiate that program.

Actually i want that program to be running like a service whenever the server is running... it can be very nice if is automatically started when the server is started/restarted.

Hoping for a solution
Jul 29 '08 #4
dlite922
1,584 Recognized Expert Top Contributor
curious,

what does the program do? does it listen on a port? does it check a file or db.table for something?




-Dan
Jul 29 '08 #5
r035198x
13,262 MVP
PHP is mainly used for web development (though not limited to). Is your program going to be a web application? Starting programs automatically when the computer boots is the easier part that. Let's first get some information on the nature of the program first.
Jul 29 '08 #6
kvijayhari
25 New Member
Yes, it an web application , gets data from the db and then process and it runs on my machine (server), the db gets updated thru my website..
Jul 29 '08 #7
r035198x
13,262 MVP
Yes, it an web application , gets data from the db and then process and it runs on my machine (server), the db gets updated thru my website..
So all you want is that the website should be available everytime the computer is switched on?
Jul 29 '08 #8
kvijayhari
25 New Member
So all you want is that the website should be available everytime the computer is switched on?
Exactly that is i want!!
Jul 29 '08 #9
r035198x
13,262 MVP
Exactly that is i want!!
If you are using Apache with your PHP then all you need to do make sure your Apache starts automatically. There are many ways of doing this depending on your distro as well. Just google for the various options and pick the one you prefer.
Jul 29 '08 #10
kvijayhari
25 New Member
If you are using Apache with your PHP then all you need to do make sure your Apache starts automatically. There are many ways of doing this depending on your distro as well. Just google for the various options and pick the one you prefer.
Thanks for your effort. But this is something different from i want..

I may not be clear in specifying what i want.

I have a website and it should run 24X7 (for this what you gave is a perfect solutions. Thanks.)

In the website , itself, i'm having a program may be an API, that has to be run indepedent of the status of the website. (i.e the specific program need not to use http connections and it has nothing to do on the client side.)

That specific API should be running on the server all the time (something like firewall..)

Can i write a program and make them running..?

I think it may be somewhat clear now.

Thanks again
Jul 29 '08 #11
r035198x
13,262 MVP
Then you create the PHP script as specified in post #3 and start it on machine boot using the same method that you would auto start Apache.
Jul 29 '08 #12
kvijayhari
25 New Member
Thanks guys.

I read that post but didn't analyzed more about that.

Thanks i'll move in that direction.
Jul 29 '08 #13
olddocks
26 New Member
Thanks guys.

I read that post but didn't analyzed more about that.

Thanks i'll move in that direction.
just place the script in CRON job.
Jul 29 '08 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: mahsa | last post by:
hi I try to upload my program in server .in the server they instal .netframework and make a virtual directory for progra but when they run in in server is shows the erro Line 44: by...
1
by: Pål Johansen | last post by:
I made a program that does screen scraping from a website, but when running this progran on a Win 2003 server the httpwebrequest works fine for a while but suddenly never returns from the request...
2
by: David Hoffer | last post by:
Can I create NET applications where the data tier is enclosed within a Web Service where the OS may be Win98SE, XP Home as well as XP Pro? The client application is a NET Forms app not a ASP.NET...
5
by: B.J. | last post by:
Hi, Where I can change Web service server side timeout ? Because my service time out and I set WebClientProtocol.Timeout to infinite. (According to...
2
by: wakun | last post by:
Hi there, I have my webpage written in C# and I am going to run an external program within the web page. I have my code like using System; using System.Diagnostics; namespace NRP { public...
4
by: kamelnet | last post by:
i created a program in server but i want to give the clients the availability to access it from thier desktops so i want to create shortcuts for that software in thier machines please any body help
1
by: kurrachaitanya | last post by:
Lecture Saying that: I am generally expecting most of you to work n java.If you prefer to use c/c++ version of the programs,you may,but the assistance in the lab sessions will be very much geared...
2
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a server 2008 IIS 7.0 with indexing service installed. I have created the catalog and have a test page using these posts:...
2
by: MedIt | last post by:
Hi All, I am trying to Post a number of requests to a web service on a client server from a console application.Through this application I am firing some 400 requests to the Web Service, one after...
1
by: rakesh patil | last post by:
i m working on content filering project i have problem in that is how i can connect web page to my program before connecting to web server
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.