Fedora startup script help

John Van Ostrand john-Da48MpWaEp0CzWx7n4ubxQ at public.gmane.org
Fri Mar 10 12:48:04 UTC 2006


On Fri, 2006-03-10 at 04:10 +0000, Muhammad Imran wrote:
> I am trying to run a perl/BASH script as a daemon upon entering run-level 3. 
> Here is what I did:
> I copied a script from /etc/init.d and modified it: put sym links in 
> /etc/rc.d/rc3.d & rc0.d
> 
> When system enters run level 3, it displays message "Starting my daemon". 
> However it doesn't detach from terminal and stays there. I am trying to run 
> it as daemon (detached from launching terminal) using daemon function in 
> shell startup script. but apparently its not working.
> 
> Can anybody suggest a way to run a perl script as daemon upon startup on 
> Fedora?
> Any help/advice is highly appreciated.

Your message is confusing. You say you wan to run a perl script in the
background but then you give a shell script example of a daemon.

The easy way to run a process in the background is a combination of
nohup and &:

	nohup mydaemon &

You might want to redirect output to a log file or to /dev/null:

	nohup mydaemon > /dev/null &

However, if your daemon is a perl script and you're okay with changing
it, then use the fork() function followed by a setsid() function in
perl. This is how a program puts itself in the background, and it's how
daemons do it. Check out the perlipc man page for an example of how to
use perl's fork.

--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list