Global Feed Post Login
Replying to Avatar Scott Williams 🐧

Want to trigger some #bash action once a process is finished? Find the pid of the process with `ps` or `top` (1234 in this example) and then:

while ps 1234 ; do sleep 5 ; done ; git add . && git commit -m 'Updated dependencies.'

The commands after the `done;` will happen once the process finishes. Keep in mind that this will fire regardless of whether it finished successfully, but this is useful for triggering an action on an already long-running process.

#Linux #scripting

Avatar
Duck Nebuchadnezzar 10mo ago

Would `set -o pipefail` work for the failure case here? I had to do something similar when I wanted a command that would do something if the first part failed, but the first part was also being piped to `tee` (which was always passing)

Reply to this note

Please Login to reply.

Discussion

No replies yet.