-1

When I connect to remote Linux server via ssh and run some command in bash shell with ampersand at the end, for some reason the process is still alive even if I exit shell or close the terminal. Bash version is 5.0.3(1).

The command example is simple as:

sleep 120 &

But it works the same way with any command I tried, for example making mysql database backup

Also tested it in zsh shell on my macbook, process gets killed when shell is exited.

So why such behaviour would be possible in bash in case I don't use nohup, screen or something that prevents killing the process?

hadouvex
  • 1
  • 1
  • `&` forces the process to run in the background. So it's not linked to your sessions and therefore it will continue running when you close the TTY. – 0stone0 Jun 02 '22 at 13:34
  • Duplicate of [How bash handles the jobs when logout?](https://stackoverflow.com/q/4298741/4154375). – pjh Jun 02 '22 at 13:48
  • Why is this tagged bash and zsh? Please restrict the scope of your question to one shell only. – user1934428 Jun 03 '22 at 12:38

0 Answers0