Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

nohup

Run a command that keeps running after you log out (it ignores the hang-up signal).

Niveau
Dagelijks Linux
Groep
Processen en jobs
Root nodig
Nee
Pakket
coreutils

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

When you close a terminal, its processes get SIGHUP and stop. nohup COMMAND & makes the command ignore SIGHUP. Output that would go to the terminal goes to nohup.out (in the current folder, or in your home folder).

For real long-running work, a systemd unit (systemd-run) or tmux is often better.

Zo schrijf je het

nohup COMMAND [ARGUMENT]...

Opties 2

Meest gebruikt

--help
Show help.
--version
Show the version.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1Keep a job running after logout

    nohup ./long-task.sh &
    nohup: ignoring input and appending output to 'nohup.out'

    Log out and come back later.

  2. 2Choose the log file

    nohup ./long-task.sh > /var/tmp/task.log 2>&1 &

    Better than nohup.out in a random folder.

  3. 3Follow the output

    tail -f nohup.out

    See the progress.

  4. 4Long copy over SSH

    nohup rsync -a /data/ server2:/data/ > rsync.log 2>&1 &

    Survives a broken SSH connection.

  5. 5Check that it still runs

    pgrep -af long-task.sh

    After you log in again.

  6. 6With low priority

    nohup nice -n 19 ./report.sh > report.log 2>&1 &

    Long and quiet.

  7. 7Stop it later

    pkill -f long-task.sh

    nohup does not protect against SIGTERM.

  8. 8Better alternative: a transient systemd unit

    systemd-run --user --unit=longtask ./long-task.sh
    journalctl --user -u longtask -f

    Logs in the journal, easy to stop with systemctl.

  9. 9Alternative: tmux

    tmux new -s work

    Detach with Ctrl+B D, attach later with tmux attach -t work.

  10. 10Mind the lingering setting

    loginctl enable-linger lisa

    With systemd, user processes may be killed at logout unless linger is on (or KillUserProcesses=no).

Exitcodes

0 :: The exit status of the command. 125 :: nohup failed. 126 :: The command could not be run. 127 :: The command was not found.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man nohup