الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

nohup

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

المستوى
لينكس اليومي
المجموعة
العمليات والمهام
يحتاج root
لا
الحزمة
coreutils

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

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.

طريقة الكتابة

nohup COMMAND [ARGUMENT]...

الخيارات 2

الأكثر استخدامًا

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

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع 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).

رموز الخروج

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

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man nohup