Skip to content

Instantly share code, notes, and snippets.

@kbbgl
Created May 7, 2020 17:02
Show Gist options
  • Save kbbgl/0dd470756018ba3aeaddea966a55a225 to your computer and use it in GitHub Desktop.
Save kbbgl/0dd470756018ba3aeaddea966a55a225 to your computer and use it in GitHub Desktop.
[run script in background] #linux #bash
# give executable permissions to script
chmod u+x run_monitoring
# run script in background and get pid for killing to stdout
nohup ./run_monitoring.sh > monitor_metrics.txt 2>&1 &
# save PID to kill
echo $! > save_pid.txt
# to kill process
kill -9 `cat save_pid.txt`
rm save_pid.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment