-   Linux - Software (
-   -   Run init script as daemon (

isuck@linux 02-10-2007 12:51 AM

Run init script as daemon
I just added a small script to my init scripts, it basically continuously reads a pipe. If I run this script from the command line without & if freezes my screen and I can't stop it. Now I wonder if the same is going to happen when I reboot. Is there any way to tell the script to run as a daemon directly? TIA 02-10-2007 08:35 AM

In whatever init file calls your init script, try putting a & after the call to your script.

For example, if your call to your init script says:


then it should now say:


/etc/rc.d/localscripts/mylocalscript &
Hope this helps.

isuck@linux 02-10-2007 07:01 PM

Thanks for your answer, I knew that one, but I meant something inside the script so I didn't have to call it with the & at the end. 02-11-2007 07:14 AM

If you're programming entirely with bash scripts, and you want to start something that continues after the boot process is complete, I don't think you can avoid "&".

alienDog 02-11-2007 07:40 AM

It's possible to avoid the &:

if [ "x$1" != "xdaemon" ]; then
$0 daemon &
exit 0

... the rest of your script goes here

isuck@linux 02-12-2007 02:29 AM

Thanks for all the answers. That's what I was looking for alienDog.

All times are GMT -5. The time now is 06:39 AM.