Starting a linux process in the background
I'm trying to create a script which starts some programs
startup.sh
knetworkmanager
emesene
keepassx
The problem is that when I run the script, it only starts knetworkmanager. This is because it'll start it, then wait until it's finished. How can I start a program without waiting for it? I don't think I can just add "&" after each command, because all processes will still be killed when the script is finished.
Solution 1:
When the shell that runs the script exits, it send a HUP signal to the processes you started. If those don't catch the signal, they will terminate. So whether just using & is sufficient depends on the application. To be safe, use nohup like that:
nohup your-program >>/dev/null 2>>/dev/null &
See the man pages for nohup and kill for more details or read the wikipedia article about nohup.
Solution 2:
No, the processes should not be killed when the script is finished if you use &
. Try it.
knetworkmanager &
emesene &
keepassx &