FlyingAtom FlyingAtom - 1 year ago 87
Linux Question

Bash running in sequence from Cronjob

# My first script
sleep 15 & wait
python & wait
python & wait
python & wait

How do I get it to wait for the previous line to finish executing before moving to the next?

It work fine when you call the bash file directly , but when called from cronjob, it's executing everything without waiting for the previous one to finish.

Sleep works fine with this but for the py file, it's executing without waiting.
I also tried the following

A; B Run A and then B, regardless of success of A
A && B Run B if A succeeded
A || B Run B if A failed
A & Run A in background.

Answer Source

Are you sure python is in the path when running from cron? It's often the case that your cron job's environment is stripped down compared to your normal shell environment since it doesn't execute the normal environment setup scripts. Does it work if you specify the full path to python?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download