ubuntu + nohup

来源:互联网 发布:office2016for mac安装 编辑:程序博客网 时间:2024/05/16 12:00
  1. 想要让python程序在后台执行(默认python文件名为xxx): nohup python xxx.py & 此时文件输出被追加到nohup.out文件中。如果已经存在nohup.out文件,则建议先将其备份删掉,再执行命令。

  2. 想要清空nohup.out文件 cat /dev/null > nohup.out 或者 cp /dev/null nohup.out

  3. 想要复制一份nohup.out文件 cp nohup.out nohup_bak.out

  4. 想要查看此时的进程状态: ps -ef|grep python 返回的就是进程状态,第二个id就是进程ID,后面显示运行时间

  5. 想要强制关闭某个进程: kill -9 pid

  6. 想要查看nohup.out文件的内容:

    head -n 100 nohup.out <查看前100行内容>

    tail -n 100 nohup.out <查看后100行内容>

    cat nohup.out|grep “关键字” <过滤关键字所在的行>

  7. 想要监控程序输出: tail -f nohup.out

0 0
原创粉丝点击