Saturday, October 26, 2024
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 96 times, 1 visits today)
Baca Juga :  Membuat auto move Junk email to Inbox

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