This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How can I use nohup command when filtering SNPs?

Hello

When filtering SNPs, the command is

bcftools view my_var.bcf | vcfutils.pl varFilter - > my_final.vcf

However, I want to use "nohup" with this command to be performed in the background.

nohup bcftools view my_var.bcf | vcfutils.pl varFilter - > my_final.vcf > logs.txt &

I used this command but it seems not working.

How I can change the command?

bcftools snp

Define 'not working'?

Pierre's suggestion is the better option, but have you looked at the log file? When you run a process with nohup and as a fork, you will often not be able to interrogate any terminal output unless you capture it in a separate file (but you will likely need to redirect stderr in to the logfile too.

2 answers

don't use nohup.

Use a terminal multiplexer like tmux or screen

if you really want to use nohup. Put your bcftools+vctutils commands in a shell script and invoke nohup myscript.sh.

Wrap your commands in a bash shell call:

nohup bash -c "bcftools view my_var.bcf | vcfutils.pl varFilter - > my_final.vcf" > logs.txt &

Or:

nohup bash -c "bcftools view my_var.bcf | vcfutils.pl varFilter - > my_final.vcf" > logs.stdout.txt 2> logs.stderr.txt &

Nothing wrong with using nohup, in my opinion. A multiplexer is well overkill to solve this.

Thanks. It seems to work well.

Log in to answer this question.