Monday, October 3, 2022
Bash Script

membuat script auto restart DNS

#!/bin/bash

nslookup google.com localhost > /dev/null

if [ $? -eq 1 ]
then
/etc/init.d/pdns stop
echo $(date) >> /tmp/monitor.log
fi

ket :

  • lookup google ke localhost
  • $? artinya jika benar hasilnya 0 , jika gagal hasilnya 1
  • -eq 1 artinya jika hasilnya 1 ( gagal )
  • maka service DNS akan di restart
  • echo $(date) artinya tanggal tiap restart service akan di kirim ke file /tmp/monitor.log
     
(Visited 39 times, 1 visits today)
Klik untuk berbagi dengan orang lain
Baca Juga :  Membuat Script grep log zimbra dan di kirim ke email

Similar Posts


Warning: Trying to access array offset on value of type bool in /home/des1gn/hendro-wibiksono.web.id/wp-content/plugins/floating-related-posts/floating-related-posts-pro.php on line 270

Warning: Trying to access array offset on value of type bool in /home/des1gn/hendro-wibiksono.web.id/wp-content/plugins/floating-related-posts/floating-related-posts-pro.php on line 270

Warning: Trying to access array offset on value of type bool in /home/des1gn/hendro-wibiksono.web.id/wp-content/plugins/floating-related-posts/floating-related-posts-pro.php on line 270

Warning: Trying to access array offset on value of type bool in /home/des1gn/hendro-wibiksono.web.id/wp-content/plugins/floating-related-posts/floating-related-posts-pro.php on line 270

Warning: Trying to access array offset on value of type bool in /home/des1gn/hendro-wibiksono.web.id/wp-content/plugins/floating-related-posts/floating-related-posts-pro.php on line 270

Warning: Trying to access array offset on value of type bool in /home/des1gn/hendro-wibiksono.web.id/wp-content/plugins/floating-related-posts/floating-related-posts-pro.php on line 270

Warning: Trying to access array offset on value of type bool in /home/des1gn/hendro-wibiksono.web.id/wp-content/plugins/floating-related-posts/floating-related-posts-pro.php on line 270

Warning: Trying to access array offset on value of type bool in /home/des1gn/hendro-wibiksono.web.id/wp-content/plugins/floating-related-posts/floating-related-posts-pro.php on line 270