If you want to execute your second task every time the first one is not running, the answer suggested by tink works:
watch -n 1 'pgrep <name of task1> || <task2>'
However, I wanted to run task2
only once as soon as task1
was finished. So I used:
watch -n 1 -g 'pgrep <name of task1>'; <task2>