هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
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
الأكثر استخدامًا
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 10
$ مستخدم عادي# بصلاحية root (أو مع sudo)
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.
2Choose the log file
nohup ./long-task.sh > /var/tmp/task.log 2>&1 &Better than nohup.out in a random folder.
3Follow the output
tail -f nohup.outSee the progress.
4Long copy over SSH
nohup rsync -a /data/ server2:/data/ > rsync.log 2>&1 &Survives a broken SSH connection.
5Check that it still runs
pgrep -af long-task.shAfter you log in again.
6With low priority
nohup nice -n 19 ./report.sh > report.log 2>&1 &Long and quiet.
7Stop it later
pkill -f long-task.shnohup does not protect against SIGTERM.
8Better alternative: a transient systemd unit
systemd-run --user --unit=longtask ./long-task.sh journalctl --user -u longtask -fLogs in the journal, easy to stop with systemctl.
9Alternative: tmux
tmux new -s workDetach with Ctrl+B D, attach later with
tmux attach -t work.10Mind the lingering setting
loginctl enable-linger lisaWith systemd, user processes may be killed at logout unless linger is on (or KillUserProcesses=no).
لا يوجد شيء يطابق هذا الفلتر.
رموز الخروج
0 | The exit status of the command. |
125 | nohup failed. |
126 | The command could not be run. |
127 | The command was not found. |