nohup python -u a.py > a.log &-u参数,python不启用缓冲,不加不会实时的输入到文件中
用脚本
#!/bin/shps -ef | grep python | cut -c 9-15| xargs kill -s 9python a.py > logs/a.log & python b.py > logs/b.log & python c.py > logs/c.log#“cut -c 9-15”是截取输入行的第9个字符到第15个字符,而这正好是进程号PID。#“xargs kill -9”中的xargs命令是用来把前面命令的输出结果(PID)作为“kill -9”命令的参数,并执行该令。可能会报如下错误bin/sh^M: bad interpreter: No such file or directory解决解决方法:修改.sh文件格式vi test.sh利用如下命令查看文件格式 :set ff 或 :set fileformat 可以看到如下信息 fileformat=dos 或 fileformat=unix 利用如下命令修改文件格式 :set ff=unix 或 :set fileformat=unix :wq