如果nohup.out中没有任何内容被打印出来,那么我认为您没有任何内容可以回显到nohup.out文件。尝试使用
set -xv
#/bin/bash
如果您使用的是bash。现在运行shell脚本时,nohup将至少有一个从shell脚本运行的python脚本条目,如下所示。
user@host用法:~/scripts$cat nohup.out
python /home/madbala/scripts/append_file.py
+ python /home/madbala/scripts/append_file.py
-
Python脚本名(对不起,我对Python不太了解):append_file.py
#!/usr/bin/python
from datetime import datetime
import time
with open("test.txt", "a") as myfile:
for x in range(15):
myfile.write('appended text %s \n' %datetime.now())
time.sleep(2)
-
调用上述python脚本的Shell脚本:run \u py \u Script.sh
#!/bin/bash
set -xv
python /home/madbala/scripts/append_file.py
nohup run_py_script.sh &
我得到的输出,因为我有
第十五套
(这实际上支持shell脚本中的详细日志记录—您也可以使用
set -x
).
当我评出
第十五套
使用
#set -xv
我们没有内容。