nohup

不挂断地运行命令

语法

  nohup Command [Arg]...

nohup 命令运行由 Command 参数和任何相关的 Arg 参数指定的命令,忽略所有挂断(SIGHUP)信号。在注销后使用 nohup 命令运行后台中的程序。要运行后台中的 nohup 命令,添加 & ( 表示“and”的符号)到命令的尾部。

无论是否将 nohup 命令的输出重定向到终端,输出都将附加到当前目录的 nohup.out 文件中。

如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中。

如果没有文件能创建或打开以用于追加,那么 Command 参数指定的命令不可调用。

退出状态:该命令返回下列出口值:

     126 可以查找但不能调用 Command 参数指定的命令
     127 nohup 命令发生错误或不能查找由 Command 参数指定的命令。   
     否则,nohup 命令的退出状态是 Command 参数指定命令的退出状态。

bash脚本,它接受命令并在后台运行它



#!/bin/bash
mkdir -p ~/launch
logfilename="${1##*/}_$(date +%F_%H:%M:%S,%N)"
echo "== LAUNCH $@ ==" > ~/launch/${logfilename}_stdout.log
echo "== LAUNCH $@ ==" > ~/launch/${logfilename}_stderr.log
nohup "$@" >>~/launch/${logfilename}_stdout.log 2>>~/launch/${logfilename}_stderr.log &


nohup 命令实例:

linux命令:nohup <command> & & <command> nohup nohup <command> &rootopen.com
linux命令:nohup <command> & & <command> nohup nohup <command> &rootopen.com
2018-01-28 17:27:48

linux命令:nohup <command> 2> /dev/null > /dev/null & & /dev/null > /dev/null 2> <command> nohup nohup <command> 2> /dev/null > /dev/null &rootopen.com
linux命令:nohup <command> 2> /dev/null > /dev/null & & /dev/null > /dev/null 2> <command> nohup nohup <command> 2> /dev/null > /dev/null &rootopen.com
2018-04-12 20:29:48

linux命令:nohup /bin/sh myscript.sh 1>&2 &>/dev/null 1>&2 &>/dev/null& &>/dev/null& 1>&2 &>/dev/null 1>&2 myscript.sh /bin/sh nohup nohup /bin/sh myscript.sh 1>&2 &>/dev/null 1>&2 &>/dev/null&rootopen.com
linux命令:nohup /bin/sh myscript.sh 1>&2 &>/dev/null 1>&2 &>/dev/null& &>/dev/null& 1>&2 &>/dev/null 1>&2 myscript.sh /bin/sh nohup nohup /bin/sh myscript.sh 1>&2 &>/dev/null 1>&2 &>/dev/null&rootopen.com
2018-03-30 06:56:48

linux命令:nohup VBoxHeadless -p 3052 -startvm ServidorProducao & & ServidorProducao -startvm 3052 -p VBoxHeadless nohup nohup VBoxHeadless -p 3052 -startvm ServidorProducao &rootopen.com
linux命令:nohup VBoxHeadless -p 3052 -startvm ServidorProducao & & ServidorProducao -startvm 3052 -p VBoxHeadless nohup nohup VBoxHeadless -p 3052 -startvm ServidorProducao &rootopen.com
2018-01-07 10:12:48

linux命令:nohup gnome-open . 0</dev/null 1>/dev/null 2>/dev/null& 2>/dev/null& 1>/dev/null 0</dev/null . gnome-open nohup nohup gnome-open . 0</dev/null 1>/dev/null 2>/dev/null&rootopen.com
linux命令:nohup gnome-open . 0</dev/null 1>/dev/null 2>/dev/null& 2>/dev/null& 1>/dev/null 0</dev/null . gnome-open nohup nohup gnome-open . 0</dev/null 1>/dev/null 2>/dev/null&rootopen.com
2018-06-01 01:25:48

linux命令:nohup nautilus & & nautilus nohup nohup nautilus &rootopen.com
linux命令:nohup nautilus & & nautilus nohup nohup nautilus &rootopen.com
2018-02-06 15:28:48

linux命令:nohup ping -i1 www.google.com & & www.google.com -i1 ping nohup nohup ping -i1 www.google.com &rootopen.com
linux命令:nohup ping -i1 www.google.com & & www.google.com -i1 ping nohup nohup ping -i1 www.google.com &rootopen.com
2018-04-08 20:30:48

linux命令:nohup df -k | sort -rn 12 12 -rn sort | -k df nohup nohup df -k | sort -rn 12rootopen.com
linux命令:nohup df -k | sort -rn 12 12 -rn sort | -k df nohup nohup df -k | sort -rn 12rootopen.com
2018-04-29 09:18:48

linux命令:nohup cat /dev/ttyS0 | tee -a llamadas.db& llamadas.db& -a tee | /dev/ttyS0 cat nohup nohup cat /dev/ttyS0 | tee -a llamadas.db&rootopen.com
linux命令:nohup cat /dev/ttyS0 | tee -a llamadas.db& llamadas.db& -a tee | /dev/ttyS0 cat nohup nohup cat /dev/ttyS0 | tee -a llamadas.db&rootopen.com
2018-02-02 15:57:48

linux命令:nohup ./my-shell-script.sh & & ./my-shell-script.sh nohup nohup ./my-shell-script.sh &rootopen.com
linux命令:nohup ./my-shell-script.sh & & ./my-shell-script.sh nohup nohup ./my-shell-script.sh &rootopen.com
2018-05-01 14:13:48

linux命令:nohup matlab -nosplash -nodesktop -nodisplay -nojvm -logfile output.log -r "function(0)" >output & & >output "function(0)" -r output.log -logfile -nojvm -nodisplay -nodesktop -nosplash matlab nohup nohup matlab -nosplash -nodesktop -nodisplay -nojvm -logfile output.log -r "function(0)" >output &rootopen.com
linux命令:nohup matlab -nosplash -nodesktop -nodisplay -nojvm -logfile output.log -r "function(0)" >output & & >output "function(0)" -r output.log -logfile -nojvm -nodisplay -nodesktop -nosplash matlab nohup nohup matlab -nosplash -nodesktop -nodisplay -nojvm -logfile output.log -r "function(0)" >output &rootopen.com
2018-02-09 05:42:48

linux命令:nohup tail /var/log/murmur.log | perl -ne '/^<.>[0-9:. -]{24}(\d+ => )?(.*)/; $pid=`pgrep -u murmur murmurd | head`; chomp $pid; `logger -p info -t "murmurd[$pid]" \\"$2\\"`;' & & \\"$2\\"`;' "murmurd[$pid]" -t info -p `logger $pid; chomp head`; | murmurd murmur -u $pid=`pgrep )?(.*)/; => -]{24}(\d+ '/^<.>[0-9:. -ne perl | /var/log/murmur.log tail nohup nohup tail /var/log/murmur.log | perl -ne '/^<.>[0-9:. -]{24}(\d+ => )?(.*)/; $pid=`pgrep -u murmur murmurd | head`; chomp $pid; `logger -p info -t "murmurd[$pid]" \\"$2\\"`;' &rootopen.com
linux命令:nohup tail /var/log/murmur.log | perl -ne '/^<.>[0-9:. -]{24}(\d+ => )?(.*)/; $pid=`pgrep -u murmur murmurd | head`; chomp $pid; `logger -p info -t "murmurd[$pid]" \\"$2\\"`;' & & \\"$2\\"`;' "murmurd[$pid]" -t info -p `logger $pid; chomp head`; | murmurd murmur -u $pid=`pgrep )?(.*)/; => -]{24}(\d+ '/^<.>[0-9:. -ne perl | /var/log/murmur.log tail nohup nohup tail /var/log/murmur.log | perl -ne '/^<.>[0-9:. -]{24}(\d+ => )?(.*)/; $pid=`pgrep -u murmur murmurd | head`; chomp $pid; `logger -p info -t "murmurd[$pid]" \\"$2\\"`;' &rootopen.com
2018-02-07 13:10:48

linux命令:nohup bash -c "while true; do ps -x | mail pascalv@mmmmail.com; sleep 3600; done" | mail pascalv@mmmmail.com & & pascalv@mmmmail.com mail | done" 3600; sleep pascalv@mmmmail.com; mail | -x ps do true; "while -c bash nohup nohup bash -c "while true; do ps -x | mail pascalv@mmmmail.com; sleep 3600; done" | mail pascalv@mmmmail.com &rootopen.com
linux命令:nohup bash -c "while true; do ps -x | mail pascalv@mmmmail.com; sleep 3600; done" | mail pascalv@mmmmail.com & & pascalv@mmmmail.com mail | done" 3600; sleep pascalv@mmmmail.com; mail | -x ps do true; "while -c bash nohup nohup bash -c "while true; do ps -x | mail pascalv@mmmmail.com; sleep 3600; done" | mail pascalv@mmmmail.com &rootopen.com
2018-05-13 03:28:48

linux命令:nohup exemplo.sh & & exemplo.sh nohup nohup exemplo.sh &rootopen.com
linux命令:nohup exemplo.sh & & exemplo.sh nohup nohup exemplo.sh &rootopen.com
2018-02-20 20:25:48

linux命令:nohup bash example.sh 2>&1 | tee -i i-like-log-files.log & & i-like-log-files.log -i tee | 2>&1 example.sh bash nohup nohup bash example.sh 2>&1 | tee -i i-like-log-files.log &rootopen.com
linux命令:nohup bash example.sh 2>&1 | tee -i i-like-log-files.log & & i-like-log-files.log -i tee | 2>&1 example.sh bash nohup nohup bash example.sh 2>&1 | tee -i i-like-log-files.log &rootopen.com
2018-03-06 13:57:48

linux命令:nohup some_command/script.sh > /dev/null 2>&1& 2>&1& /dev/null > some_command/script.sh nohup nohup some_command/script.sh > /dev/null 2>&1&rootopen.com
linux命令:nohup some_command/script.sh > /dev/null 2>&1& 2>&1& /dev/null > some_command/script.sh nohup nohup some_command/script.sh > /dev/null 2>&1&rootopen.com
2018-04-07 14:52:48

Linux的Bash命令行(A-Z排序)