i am running python scripts on a ubuntu server though cronjob bellow is my bash file content
#!/bin/bash
cd /home/ubuntu/
PATH=$PATH:/usr/local/bin
export PATH
nohup scrapy crawl first_job &
nohup scrapy crawl second_job &
nohup scrapy crawl third_job &
wait $(pgrep third_job)
nohup scrapy crawl fourth_job &
what i want is fourth_job start executing as soon as third_job complete
but
currently even if third_job complete , fouth_job wait for the completion of first_job and second_job
thanks in advance
A Safer way to get a PID of the last background process is to remember the value of $!: