Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make a simple script process a daemon process

Status
Not open for further replies.

whanner

ISP
Jul 28, 2002
16
US
I want to be able to create a simple process (like a sleep command)to run as a daemon process for testing purposes.
any ideal how I can do this. I would like it to run until I kill it and run under what ever process name I give it.
 
call your script procsleep in there have

while true
do
sleep 5
done

change permissions of script 755
run your script

./procsleep &

do ps -ef | grep procsleep

( it should be running until you kill it)

 
I tried that...all I get is the sleep and not the process name I called it.
 
if you start you prosleep with

sh ./procsleep &

then the ps will keep the process name in the process table.
I'm sure there are other ways (ie how you invoke "sleep"). but this works.
 
The main process will be the script i.e. procsleep
from this you will have a child process called sleep
if you kill the main process procsleep that will kill th sleep process , because its the child
 
Is there an easy way to do this though an init.d script? In an example RedHat Linux init.d script you have functions that you include and one of which is 'daemon' which launches a process, but apparently you cannot use '&'.

I would need a way to detach the process within the script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top