#!/usr/bin/env bash # Install in /root/bin/ (create if 'bin' doesn't exist). # sudo crontab -e # * * * * * sh /root/bin/openvpn_restart.sh # To disable logging, leave as "/dev/null" otherwise change to a file such as "/root/openvpn_status.log" LOG="/dev/null" PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games /bin/date >> $LOG 2>&1 /bin/echo "$PATH" >> $LOG 2>&1 /sbin/ifconfig tun >> $LOG 2>&1 if [ "$?" -ne 0 ] then /usr/sbin/service openvpn restart >> $LOG 2>&1 fi #if [ "$?" -ne 0 ]