I connecting from laptop to my ubuntu-server via SSH, log into the system, and execute, for example, a command like

apt install openjdk-13-jre-headless

The download starts, but if I close my SSH connection the process is terminated. How can I handle it to stop process terminating after log-out? Is it possible and safe?

2 Answers 2


Yes, this is possible (in most of the cases) and safe. The command should be something like:

nohup apt install openjdk-13-jre-headless >/path/to/log 2>/path/to/errors &

nohup command deattach the process from terminal (like a daemon) and & put it in background


You can use the command nohup

nohup apt install openjdk-13-jre-headless &

If I remember well, the command won't stop if you close your ssh session and will write the output into a file named nohup.out

You also can use screen

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .