Kill nohup bash process
1
0
Entering edit mode
4.9 years ago

Hey guys,

I ran this

nohup bash -c 'for next in $(cat all_bacteria_links.txt); do wget -P all_bacteria "$next"/*genomic.fna.gz; done',

and now I want to kill the process. I ran the command in ssh server, so whenever I try to kill PID or kill -9 PID, the server connection closes. Can you please let me know how I can kill this process? Thanks!

genome sequence • 7.3k views
ADD COMMENT
1
Entering edit mode
ADD REPLY
0
Entering edit mode

You're killing the wrong bash process.

ADD REPLY
0
Entering edit mode

Do ps -ef | grep all_bacteria_links and kill the right process.

ADD REPLY
2
Entering edit mode

Pro tip: use a decoy character class with the grep following the ps to avoid listing the grep as one of the candidates.

ps -ef | grep "[a]ll_bacteria_links"

The pattern [a]ll doesn't match the string "[a]ll", so the grep process won't be picked.

ADD REPLY
1
Entering edit mode

OP has a very convoluted way to run the command by running a bash shell with nohup, so the process to kill is bash.

ADD REPLY
2
Entering edit mode

I believe there is a specific corner in hell for people who do this, no?

ADD REPLY
0
Entering edit mode

It doesn't work, because the PID is always changing on the server... So, I found a solution:

pkill -STOP -P the_ppid

Thanks anyway guys!

ADD REPLY
8
Entering edit mode
4.9 years ago

Hi, I'd recommend using screen instead of nohup, screen is safer.

And, you better utilize some batch commands like parallel to accelerate thousands of jobs, here is wget.

Using wget -c to resume unfinished download is also recommended.

Here's my method in this case from Manipulation on NCBI refseq bacterial assembly summary

$ cat mt.tsv | csvtk cut -t -f ftp_path | sed 1d \
    | rush -v prefix='{}/{%}' \
        '   wget -c {prefix}_genomic.fna.gz; \
            wget -c {prefix}_genomic.gbff.gz; \
            wget -c {prefix}_genomic.gff.gz; \
            wget -c {prefix}_cds_from_genomic.fna.gz \
            wget -c {prefix}_protein.faa.gz; \
        ' \
        -j 10 -c -C download.rush

If the process died for some reasons like PC reboot or network interrupt, just re-run the command, which will ignore finished jobs recorded in file download.rush.

ADD COMMENT
0
Entering edit mode

THIS is the right solution!

ADD REPLY

Login before adding your answer.

Traffic: 2579 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6