You are not logged in.
Hallo,
i want to start a shell script from Cinnamon starter (desktop icon). The command in the starter is: sudo /home/user/bin/myscript.sh. The script should manually start a vnc server on-demand (beside other things not relevant here. Sudo is needed for other stuff). VNC works if started manually.
This is the content of the script:
#!/bin/sh
nohup x0vncserver -display :0 -passwordfile /home/user/.vnc/passwd &
sleep 5
The vnc server (process) only lives as long as the terminal (5 seconds). The 'nohup.out' just shows 'Terminated'.
Why is this happening? How can i keep the process running after the terminal closes?
Last edited by Maniaxx (2016-09-17 19:52:39)
sys2064
Offline
Have you just tried "exec .." ? and then don't background the process (&) but instead no nothing. The process should live on as long as your user is logged in.
Offline
Then it hangs there. Appending a '&' gives same '5 seconds' result.
sys2064
Offline
The vnc server (process) only lives as long as the terminal (5 seconds).
Terminal? What terminal? Do you just mean the parent process?
You should probably use setsid not nohup.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Sorry, i meant the shell window that opens once you double click the icon. Not a terminal indeed.
And yes, setsid works indeed. Never heard of it but i learned something today.
Thanks!
Last edited by Maniaxx (2016-09-17 03:26:41)
sys2064
Offline
If a shell window opens, then it is a terminal emulator. But there really shouldn't be - you should be able to set it to not open the terminal window.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Shell window is intended. It gives me feedback about proper execution. I spawn VNC, OpenVPN, NFS services, mount NTFS drives and bind mount some folders to my NFS exports. The script will close immediately due to 'set -e' if anything goes wrong. I don't want to have this stuff permanently running.
sys2064
Offline