Shell script does not work with nohup

I am trying to run a shell script using the nohup command. The shell script takes an array of files, runs a python program for each file in the loop, and adds the output to the file. This works fine on the server, but if I try to use the nohup command, it will not work. I successfully run other programs using nohup on this server, not this script.

#!/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

The program works fine when I run it while remaining connected to the server, for example

./batch.sh > /dev/null &
./batch.sh > ./output.txt &

However, when I try to run it with the nohup command,

nohup ./batch.sh > /dev/null &

If I exit the server and return, the output file (batch_results.dat) will not have any data.

I am sure that the simplest fix or command is missing here. Any ideas?

: fof.py , mdisk5.py. nohup, , "0010.dat". batch0.dat batch_results.dat .

+5
1

:

#!/Bin/

sh . shebang, , , bash, , ,

   DAT_FILES="0010.dat 0020.dat 0030.dat"
   for file in $DAT_FILES
   do
       ...
   done
+1

All Articles