nohup

nohup 功能说明:将程序以忽略挂起信号的方式运行起来,被运行程序的输出信息将不会显示到终端。
输出将写入到当前目录的nohup.out文件中。如果当前目录的nohup.out文件不可写,则输出到 $HOME/nohup.out 中

重要提示:
nohup后台运行命令,关闭shell后进程会终止

当用 nohup 执行脚本:
nohup sh /tmp/import_mysql_data.sh &

关闭shell时,再打开shell ,发现进程会退出。

解决办法:
输入exit命令退出终端


范例:
[root@testdb62 ~]# nohup ping baidu.com &
[1] 16923
[root@testdb62 ~]# nohup: ignoring input and appending output to ‘nohup.out’
[root@testdb62 ~]# tail -f nohup.out 
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2013 (HY000) at line 481: Lost connection to MySQL server during query
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=49 time=31.2 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=49 time=29.9 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=49 time=31.5 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=49 time=29.9 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=5 ttl=49 time=30.0 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=6 ttl=49 time=31.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=7 ttl=49 time=29.8 ms




原文地址:https://www.cnblogs.com/l10n/p/14178187.html