Skip to content

Instantly share code, notes, and snippets.

@HackingGate
Created February 1, 2016 04:11
Show Gist options
  • Save HackingGate/ebaa3279e989aaf6a334 to your computer and use it in GitHub Desktop.
Save HackingGate/ebaa3279e989aaf6a334 to your computer and use it in GitHub Desktop.
A watchdog for Pcap-DNSProxy on OpenWrt
PROG=/usr/sbin/Pcap_DNSProxy
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
if [ $(ps|grep ${PROG}|grep -v grep|wc -l) -ge 1 ]; then
echo "['$LOGTIME'] Pcap_DNSProxy is running, PID is $(pidof ${PROG##*/})"
else
echo "['$LOGTIME'] Pcap_DNSProxy is not running."
/etc/init.d/pcap-dnsproxy start
fi
@HackingGate
Copy link
Author

HackingGate commented Jun 29, 2016

You can edit crontab tasks with:
crontab -e

Copy and paste:

# run every minutes 
* * * * * /root/pcap-dnsproxy-watchdog.sh >> /var/log/pcap-dnsproxy-watchdog.log 2>&1
# clean log every week at 1am
0 1 * * 7 echo "" > /var/log/pcap-dnsproxy-watchdog.log

Cron is not enabled by default, so your shell script won't be run scheduled. To activate cron:

/etc/init.d/cron start
/etc/init.d/cron enable

@HackingGate
Copy link
Author

To clean dns:

/etc/init.d/pcap-dnsproxy flush
killall dnsmasq
/etc/init.d/dnsmasq start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment