5
我想用nohup命令运行一个shell脚本。 shell脚本获取一组文件,在循环中的每个文件上运行python程序,并将输出附加到文件中。这在服务器上工作正常,但如果我尝试使用nohup命令它不起作用。我已经成功地在这个服务器上使用nohup运行其他程序,只是没有这个脚本。shell脚本不能与nohup一起工作
#!/bin/sh
ARRAY=(0010.dat 0020.dat 0030.dat)
rm batch_results.dat
touch batch0.dat
touch batch_results.dat
for file in ${ARRAY[@]}
do
python fof.py $file > /dev/null
python mdisk5.py > ./batch0.dat
tail -1 batch0.dat
tail -1 batch0.dat >> batch_results.dat
done
程序工作正常,当我运行它,同时保持连接到服务器,例如
./batch.sh > /dev/null &
./batch.sh > ./output.txt &
然而,当我尝试使用nohup命令运行它,
nohup ./batch.sh > /dev/null &
如果我退出服务器并返回输出文件(batch_results.dat)没有任何数据。
我相信我在这里错过了一些简单的修复或命令。有任何想法吗?
编辑: 程序fof.py生成两个文件,用作mdisk5.py的输入。 当我在运行nohup时退出服务器时,会生成这两个文件,但仅限于第一个输入文件“0010.dat”。输出文件batch0.dat和batch_results.dat保持空白。
取出'>的/ dev/null'看如果有任何有用的信息被打印?另外,不nohup把任何输出到文件'nohup.txt'或类似?祝你好运。 – shellter 2012-02-15 18:05:56
我在工作目录中找不到nohup.txt文件。这是否会转到不同的默认目录? – ricitron 2012-02-15 18:47:19
我刚刚搜索的nohup文档说它是当前目录或$ HOME。在命令行'man nohup'上试试看看你系统的细节。祝你好运。 – shellter 2012-02-15 18:50:10