Created
September 10, 2021 10:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "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