check port status and the send email

I have once shell script which check the port status every minute.If the status of port is down then it will send email.But this will send email every minute until port is again up.But I want to send email after 30 minutes from 1st mail sent.How can i do this?I call PHP file from shell script to send mail.

nc -v -z -w 10 192.168.50.34 5038;

output=$?

echo $output

php=which php

dt=date;

$php send_ast_status.php $output $dt

if [ $output == “0” ];
then

echo ‘asterisk is running’

/etc/init.d/asterisk 'stop'

else

echo ‘asterisk not running’

  /etc/init.d/asterisk 'start'

fi


Source: shell

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.