Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-01-2007, 09:40 AM   #1
LQ Newbie
Registered: Apr 2007
Posts: 5

Rep: Reputation: Disabled
Construct a Service

hi all
i have a program that should be always run in background.
but i don't know how to construct it like a service.

(my program written by php and is a single file but is not a web application and run by:
/usr/local/bin/php -q /<path of file>
this file is a sms engine that always connect to database and send my user sms)

may you help me please?

Last edited by amirsarb; 06-01-2007 at 10:12 AM.
Old 06-01-2007, 09:54 AM   #2
Senior Member
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (
Posts: 1,900

Rep: Reputation: 69
What distribution do you use? Generally, you can either add
/usr/local/bin/php -q /<path of file> & disown
to /etc/rc.local (or where it is located) or write a shell script to launch you program, put it in /etc/init.d (or /etc/rc.d/init.d) and place a link to it with name starting with S99 in /etc/rcS.d (again /etc/rc.d/rcS.d is possible).
Old 06-01-2007, 09:58 AM   #3
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Well, if you were using C, I'd suggest using the daemon() call. In your case the best bet may just be to nohup it and put it in the background.

nohup script_with_php_call &

this would allow you to close the controlling terminal, but it would not give you any fault tolerance like a true service, ie. if the process dies it will be restarted.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make TCP server a daemon / service much like a dhcpd service? rajat Linux - Networking 1 05-22-2007 01:29 AM
C++: construct object at certain address addy86 Programming 18 07-22-2006 05:17 PM
getting rpoblem in assigning value to variable in if construct Ankit mittal Programming 9 01-07-2006 09:12 AM
how-to construct execution trees when using yacc sibtay Programming 0 12-30-2004 06:32 AM
Help me construct an Xmms Skin mini-Howto Please read! shassouneh Linux - General 3 05-01-2002 06:05 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration