![]() |
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
|
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: Code:
/etc/rc.d/localscripts/mylocalscriptCode:
/etc/rc.d/localscripts/mylocalscript & |
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.
|
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 "&".
|
It's possible to avoid the &:
#!/bin/bash if [ "x$1" != "xdaemon" ]; then $0 daemon & exit 0 fi ... the rest of your script goes here |
Thanks for all the answers. That's what I was looking for alienDog.
|
| All times are GMT -5. The time now is 12:34 AM. |