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 5038;


echo $output

php=which php


$php send_ast_status.php $output $dt

if [ $output == “0” ];

echo ‘asterisk is running’

/etc/init.d/asterisk 'stop'


echo ‘asterisk not running’

  /etc/init.d/asterisk 'start'


Source: shell

Leave a Reply

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