1 year ago
#354093
Matt
Kill a process when it gives certain logging output (zsh/mac)
I have a long running build process that I want to terminate after a certain log output is given.
What i normally do is just watch the process running and when the log entry appears I control-c
. Is there a better way to do this, im a Windows guy so dont know where to start.
The command I am running is npx nx run myapp:ios
and the log line is Project successfully prepared (ios)
As per Josh Friedlander's comment I have tried the following command and variations but cannot get it to work, the process continues beyond the log line defined:
npm run mybuildscript | while read -r LOGLINE; do echo ${LOGLINE}; [[ "${LOGLINE}" == "Project successfully prepared (ios)" ]] && pkill -P $$ npm; done
ios
linux
macos
zsh
nomachine-nx
0 Answers
Your Answer