Timeline for Run a bash command when a process is done
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 13, 2020 at 21:13 | history | edited | Kusalananda♦ | CC BY-SA 4.0 | added 138 characters in body |
| Mar 13, 2020 at 20:31 | comment | added | l0b0 | This method is brittle, as shown by the above comments, and complex too. | |
| Mar 13, 2020 at 11:16 | comment | added | Kusalananda♦ | @GuntramBlohmsupportsMonica You could obviously use pgrep -u "$USER" ... on a multi-user system. Using pgrep would also avoid issues arising from PID reuse on heavily used systems. | |
| Mar 13, 2020 at 11:08 | comment | added | Guntram Blohm | I'd prefer running ps once to find out the pid of that first script, then run a loop like while kill -0 <pid>. Had it happen way too often that pgrep (or killall) found something that wasn't intended, especially on multi-user systems. Btw, kill -0 won't do anything to the killed process, it just checks if that process is still there. | |
| Mar 13, 2020 at 6:43 | comment | added | emremrah | First one is really useful, thank you! And yes, I can use the second one too in most cases, but first one is neat. | |
| Mar 12, 2020 at 23:29 | history | answered | Kusalananda♦ | CC BY-SA 4.0 |