I issue a command task1 & task2 dir/ && task3 &
Issuing: jobs -l
will show:
[1]- 39281 Running task1 &
[2]+ 39282 Running task2 && task3 &
Issuing: ps
will show:
39281 ttys002 0:04.17 task1
39282 ttys002 0:00.00 task2
39283 ttys002 0:03.66 task3
Questions:
Goal: Issue a single line of commands to init a workflow and send it to the background. When ready kill all started processes in one go.
For context and in my case, task1 is a grunt task with livereload, so it should be sent to the background. Task2 changes the directory so that task3 can watch files changed in that directory.
Using bash with job control you can kill the most recent two background tasks more-or-less simultaneously with
kill %% %-
If you want the job not to show the cd
part you'll need to change the directory in the current shell, which means isolating the cd
expression:
sleep 10000 & cd .. && { sleep 20000 & }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With