Skip to content

Instantly share code, notes, and snippets.

@satr
Created September 10, 2021 10:19
Show Gist options
  • Save satr/9453f59369c73b444cbd12da4c4fa9e4 to your computer and use it in GitHub Desktop.
Save satr/9453f59369c73b444cbd12da4c4fa9e4 to your computer and use it in GitHub Desktop.
Shell command to ping URL in loop and kill a process by name when URL is not responding
# "gedit" - here your programm to start and kill
# http://localhost:9000 - URL to ping (expecting code 200 for success)
# sleep 1 - period in seconds
nohup gedit & while [ 200 == $(curl -o /dev/null --silent -Iw '%{http_code}' http://localhost:9000) ]; do echo 'ping'; sleep 1 ; done; kill $(pgrep gedit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment