Use tmux when you may need to reconnect and see the work; use nohup for a simple non-interactive command; use disown -h only when a job is already running; and use systemd-run when the process should be managed as a transient service. An SSH logout normally causes the shell to send SIGHUP (the hang-up signal) to child processes, so unprotected jobs often exit. The methods below prevent that signal from terminating the work or move the work into a persistent manager.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
Why an SSH disconnect kills your process
SSH gives you a remote login shell attached to a terminal. When you log out, close the terminal, or lose the connection, that session ends. The shell then sends SIGHUP to processes associated with the session. Most ordinary child processes quit when they receive it, which is why a script can appear to work normally and then vanish as soon as your laptop sleeps or the network drops.
As an Amazon Associate I earn from qualifying purchases.
The solution is not to keep the SSH window open. Instead, start the command in a way that either ignores SIGHUP, removes it from the shell’s job management, runs it inside a persistent terminal multiplexer, or hands it to the service manager. These choices protect against an SSH logout, but they are not automatically a reboot strategy. Whether a job returns after a server reboot depends on a separate service configuration and is not established by these four commands.
Choose the method that matches the job
| Method | Survives SSH logout | Reconnect and see the same terminal | Managed by a service manager | Does it background the command itself? | Best use |
|---|---|---|---|---|---|
nohup plus & |
Yes, when invoked correctly | No | No | No; add & |
A one-shot, non-interactive script or command |
disown -h |
Yes, when applied to the correct background job | No | No | No; the job must already be stopped or backgrounded | Protecting a command you forgot to prepare before logout |
tmux (or screen) |
Yes | Yes | No | The multiplexer keeps a session; you run the command inside it | Interactive work, long builds, monitoring, and anything you may need to inspect |
systemd-run |
Yes, as a detached transient unit | No terminal reattachment | Yes | Service units start asynchronously by default; scope units wait | Work that should have a named unit and service-manager lifecycle |
If you are unsure, start with tmux. It gives you a way back into the running shell, so you can observe progress, answer prompts, or stop the command cleanly. Choose nohup when the command is fully unattended and you only need it to continue.
#1 Best Overall
Run a simple command with nohup
What nohup changes
nohup starts another program with SIGHUP ignored. The signal disposition is changed immediately before the command is executed, so a later logout does not normally terminate that command because of the hang-up signal. POSIX specifies this signal handling at invocation.
nohup does not put the command in the background. Without an ampersand, your shell remains occupied until the command finishes, even though the command is protected from SIGHUP. The usual pattern is:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallnohup ./backup.sh > backup.log 2>&1 &
Here, the script is started with SIGHUP ignored, standard output is written to backup.log, standard error is merged into that same file, and the final & returns your prompt so you can log out.
Where output goes
If nohup sees that standard output is still a terminal, it redirects output to a file named nohup.out. It uses the current directory when possible, or $HOME/nohup.out as a fallback. Explicit redirection is safer because it gives the log a predictable name and prevents you from having to search for a file after disconnecting.
Use a separate log for each significant run rather than allowing unrelated commands to append to one shared file. For example:
nohup ./import-data.sh > import-2026-10-14.log 2>&1 &
Record the process identifier printed by your shell, or note the command name and log path. After reconnecting, inspect the log to determine whether the program completed; the fact that the SSH window closed successfully does not prove that the command finished successfully.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →When nohup is the wrong tool
- You need to interact with the program. A command that asks questions, displays a live dashboard, or requires occasional input is better inside
tmuxorscreen. - You forgot to use it. You cannot retroactively wrap an already-running process with
nohup; use the job-control procedure in the disown section if the shell still owns the job. - You expect full daemon behavior.
nohupignoresSIGHUP, but it is not a complete daemonization framework. It does not provide a service unit, restart policy, or a reattachable terminal. - The command has its own shutdown logic. A program can exit for reasons unrelated to
SIGHUP, such as an application error, a lost dependency, or an explicit timeout. Protecting the signal does not remove those failure modes.
Protect an already-running job with disown
How job control is involved
disown is a shell built-in that changes how the shell treats one of its jobs. The commonly reported form disown -h %1 keeps job 1 in the shell’s job table but prevents that job from receiving SIGHUP when the shell exits. This is useful when a command is already running and you did not start it with nohup.
The job must be stopped or running in the background before you can disown it. In an interactive shell, press Ctrl-Z to suspend the foreground command, resume it in the background with bg, and then apply disown -h to the correct job number.
- Press
Ctrl-Zwhile the command is in the foreground. - Run
jobsand identify the job specification, such as%1. - Resume that job:
bg %1. - Block the hang-up signal for it:
disown -h %1. - Confirm the shell has returned to a prompt, then disconnect.
Replace %1 with the number shown by jobs. Disowning the wrong job protects the wrong process, while leaving the intended job managed by the shell can still result in termination at logout.
Disown’s limitations
Shell job-control syntax and option details vary, so check the disown entry in the man page or built-in help on the target shell before relying on a flag in a production session. The procedure also depends on the original shell still being alive and still knowing about the job. If the SSH connection has already disappeared and the shell is gone, there is no remaining job table in which to run disown.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Disown does not create a reattachable terminal and does not give you a service-manager unit. It is a rescue technique for a job you have already started, not a replacement for planning long-running work.
Use tmux for a persistent, reattachable session
Start and detach a tmux session
tmux separates a terminal session into a server and one or more clients. The server and its sessions continue on the remote host when your SSH client disconnects. You can later create a new SSH connection and attach to the same session.
- Start a named session:
tmux new -s backup. - Run your command inside that session, for example
./backup.sh. - Detach without stopping the command by pressing
Ctrl-B, thenD. - Close SSH. The tmux server remains on the remote machine.
- Reconnect and run
tmux attach -t backupto see the existing terminal again.
Use a meaningful session name such as backup, build, or migration. Names make it easier to select the right work when several sessions are active. If you omit the target name while attaching, tmux can attach to an available session; specifying the name avoids ambiguity.
Why tmux is safer for interactive work
Unlike nohup and disown, tmux preserves the terminal context. Output remains visible when you reattach, and you can answer a prompt, inspect a live command, or interrupt it deliberately. A temporary network failure is treated as a detached client rather than as the end of the remote shell that owns the work.
tmux does not make a failing application reliable. If the command exits because of an error, the tmux window will still be there, but the process will not restart automatically. For restart and service lifecycle requirements, use a service manager instead.
screen as an alternative
screen provides the same broad model: start a persistent session, run the command inside it, detach, and later reattach. It is useful on systems where screen is already installed or is the local standard. The key property is persistence of the remote terminal session, not the particular multiplexer name.
Hand the command to systemd-run
Transient service units
systemd-run asks systemd to create a transient unit for a command. A service unit runs under the service manager, detached from your interactive shell, and starts asynchronously by default. Give it a stable name with --unit=:
systemd-run --unit=backup-job ./backup.sh
The unit name lets you distinguish this job from other transient work and gives administrators a clear object to inspect using the host’s normal systemd tooling. The process is no longer dependent on the lifetime of your SSH shell in the way an ordinary child process is.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsRank #4
Scope units
A scope unit is another mode of systemd-run. It runs the command as a child of systemd-run and waits for that command to finish. Use the scope form when the caller should remain attached until completion:
systemd-run --scope --unit=backup-job ./backup.sh
Because a scope waits, it is not interchangeable with the default service behavior when your immediate goal is to return to the prompt and disconnect. Choose deliberately: service units are detached and asynchronous by default; scopes keep the invoking command waiting for completion.
Set unit properties when needed
systemd-run accepts --property= options so you can assign supported unit properties at launch. The exact property names and permissions depend on the systemd version and host policy, so verify them in the target machine’s systemd-run(1) documentation before deploying a command. A property option changes how systemd manages the unit; it does not turn a terminal session into tmux or provide terminal reattachment.
Step-by-step decision guide
Choose nohup for a fire-and-forget batch task
Select nohup when the program needs no interaction after launch, you are comfortable reading a log later, and you only need protection from the SSH logout signal. Use explicit output redirection and the trailing ampersand. This is the shortest command and has the fewest moving parts.
Choose tmux when observation or input matters
Select tmux when you may need to watch progress, respond to a prompt, inspect a live console, or reconnect after an accidental disconnect. Start the named session before launching the work; do not wait until the network is unstable.
Choose disown only after the command is already running
Select disown -h when stopping and restarting the operation would be costly and the original shell still owns a background job. It is faster than rebuilding the command, but it offers neither logs by itself nor a way to reconnect to the terminal.
Best Value
Choose systemd-run for service-style control
Select systemd-run when the process should appear as a named unit under systemd and be separated from the interactive shell. Decide whether the default asynchronous service unit or a waiting scope matches the workflow, and confirm that your account is allowed to create the requested unit.
Verify that the process really survived
- Launch with one method. Avoid testing several wrappers around the same command; otherwise you may not know which process is still running.
- Note the method-specific identifier. Save the log filename for nohup, the job number for disown, the session name for tmux, or the unit name for systemd-run.
- Disconnect deliberately. Log out or close the SSH client instead of merely opening another terminal.
- Reconnect as the same remote user. A tmux session, shell job, or unit may belong to a different account.
- Check the result. Reopen the tmux session, inspect the log, or query the process and unit with the host’s normal process and systemd tools. Confirm that the command is still making progress rather than merely leaving an empty shell behind.
Test with a harmless command before entrusting a long migration or backup to a new server. A short controlled run exposes shell differences, permission restrictions, logging mistakes, and missing utilities while recovery is easy.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Troubleshoot common failures
The process still exits immediately after logout
Check that the command was actually started through the protection method. With nohup, the ampersand belongs at the end of the complete command, and output redirection must be attached to that command. With disown, confirm the job number from jobs before applying disown -h. With tmux, make sure the command was launched inside the tmux session rather than in the original SSH shell.
You cannot find nohup.out
Look first in the working directory and then in $HOME/nohup.out. Better still, launch the command again with an explicit log path such as > backup.log 2>&1. The fallback filename is only used when standard output is a terminal; explicit redirection removes that uncertainty.
disown reports no such job
Run jobs in the same shell that started the command. A process launched by another SSH login, a different shell, or a shell that has already exited will not appear in your current job table. If the command is still recoverable, restart it inside tmux or launch it with nohup instead of guessing at a job number.
tmux attach finds no session
Use the same remote account that created the session and attach to the correct host. A session name is local to that machine and user context. If the command already exited, the session may remain but show a completed shell; if the tmux server itself was terminated, there is no session to attach to and the original process must be recovered by another method.
Recommended Free Tools
systemd-run behaves differently than expected
Check whether you used the default service mode or --scope. A service starts asynchronously, while a scope waits for its child command. Also verify the requested unit name and properties against the installed systemd documentation and your account’s permissions. A successful launch only means systemd accepted the unit; inspect the unit and its output to determine the command’s actual result.
Important boundaries
These techniques address the SSH-session boundary and the SIGHUP signal. They do not guarantee survival of a machine reboot, kernel failure, power loss, resource exhaustion, or an application-level crash. They also do not automatically restart a failed process. If a workload must return after reboot or recover from failure, design a persistent system service separately rather than treating nohup, disown, tmux, or screen as a substitute.
For a single unattended command, the practical default is nohup command > log 2>&1 &. For anything you may need to inspect, use a named tmux session. If the job is already running, use Ctrl-Z, bg, and disown -h before closing SSH. When systemd should own the lifecycle, launch a named transient unit with systemd-run.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




