linux后台运行程序--nobup

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

例如:
nohup python -u test.py > nohup.out 2>&1 & 解决 python后台运行无输出的问题

查看nohup.out里面的日志
tail -f nohup.out 其中tail是为了看文件的尾部,因为nohup.out是时时更新的,所以用tail -f查看时时更新的内容
tail -fn 50 nohup.out #50行

posted @ 2018-11-18 23:14  WayneLiu123  阅读(738)  评论(0编辑  收藏  举报