Close SSH shell and leave process running

58 views
Skip to first unread message

Klaus Siegesleitner

unread,
Jan 29, 2014, 6:40:08 PM1/29/14
to minno...@googlegroups.com
Hi All!

I tried 3 ways to leave a process running when i exit a ssh shell:
  1. nohup <cmd> &; exit
  2. <cmd> &; disown %1; exit
  3. with screen command

Each time the process is terminated!

When I show the process tree before exitting the shell I get the following output:

systemd-+-2*[agetty]
        |-sshd---bash-+-main.elf
        |             `-pstree
...

sshd is still the parent of main.elf. Exiting the shell terminates main.elf.
When I try this on my debian machine, init  becomes parent of main.elf after exiting the shell, and main.elf continues running.

So, is there a difference in Angstom / systemd?

Thanks,
Klaus!

sels...@gmail.com

unread,
Jan 30, 2014, 5:44:43 AM1/30/14
to elinux-mi...@lists.elinux.org, minno...@googlegroups.com, Klaus Siegesleitner
On 29/01/14 23:40, Klaus Siegesleitner wrote:
> Hi All!
>
> I tried 3 ways to leave a process running when i exit a ssh shell:
>
> 1. nohup <cmd> &; exit
> 2. <cmd> &; disown %1; exit
> 3. with screen command
>
> Each time the process is terminated!


That's a systemd 'feature'. It uses cgroups to track all processes started by the parent, sshd in your case, and when the parent goes away, for whatever reason, it kills off anything left in the same cgroup.

There's been plenty of holy wars started over systemd and I won't repeat them here. Instead I'll just suggest that if systemd doesn't support your use case, then perhaps you can switch to a distro that doesn't use it. As the minnow is x86 you have the widest range of choices available.

Reply all
Reply to author
Forward
0 new messages