Ubuntu16.04 -- 后台进程Nohup

  • nohup用于使程序在用户退出登陆、关闭终端之后仍能继续运行

  • 用法:

nohup your_command & #(符号&使程序在后台运行)
exit #(退出nohup模式)
  • 启动后,会将程序运行输出记录在当前目录下的nohup.out文件下,如果当前目录不可写,则会被记录在Home目录下的nohup.out文件中

  • 自定义日志文件

nohup your_command > my_nohup.log 2>&1 &
#(将日志输出在my_nohup.log文件中,并将stderr重定向至stdout)
  • 退出nohup模式之后,停止程序:
ps -ef|grep "your_command" #(查找运行该命令的进程)
kill -9 your_command_pid #(根据进程号关闭程序)

 

posted @ 2017-10-24 08:17  ma_fighting  阅读(6289)  评论(0编辑  收藏  举报
历史天气查