Skip to content

if host pings execute command

if ping -c 1 $HOST > /dev/null
   echo your command
  • replace for your desired hostname or ip
  • ping sends only one package (-c 1) and ignores the text output
  • a ping is successful returns 0 and the if proceeds
  • replace the echo line with your command
Published inenglish

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *