Question

I am trying to run a Python script (qTrimHIV.py) on ALL the files ending in .fastq in the current directory. I'd like to append nohup at the beginning so that it does all the files out from a single command, and no matter if I close the terminal or logout.

The individual command:

for x in $(find . -name '*fastq'); do echo $x; python ../qTrimHIV.py -verbose -fastq $x -l 23 -m 20 -w 23 -o ${x%.fastq*}tr -mode 2; done

works well. But when I put nohup in front of the batch command:

nohup for x in $(find . -name '*fastq') ; do echo $x; python ../qTrimHIV.py -verbose -fastq $x -l 23 -m 20 -w 23 -o ${x%.fastq*}tr -mode 2; done
-bash: syntax error near unexpected token `do'

I get the error above.

However, it works well if I put the nohup before the actual command "python ../qTrimHIV.py ", but this is not really what I want, as I want to submit the task for all files at once and have it running until it's done, without having to keep logged in.

I've tried

for x in $(find . -name '*fastq') ; do echo $x; python ../qTrimHIV.py -verbose -fastq $x -l 23 -m 20 -w 23 -o ${x%.fastq*}qtrim -mode 2; done | at now 

but it doesn't let me see the progress of the job, and I can't know if it is still running or not.

Can anyone give me any suggestions? Should I use a different command, other than nohup?

Was it helpful?

Solution

you can use:

nohup bash -c 'your command, everything including for'

also, why not to run shell script using nohup:

nohup <your script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top