I'm looking for a sh script (that I will run in cron) that checks if openvpn client is up, and if not start the service.
I'm new in scripting so please bear with me a little..
So my questions are;
I don't now what to put in the script if the check is ok, so nothing has te be done.
ps | grep -v grep | grep $service | wc -l gives 0 as output, but when openvpn is running and when it's not. So not the correct code
#!/bin/sh
service=/etc/init.d/openvpn
# Is openvpn running? If not start openvpn
if (( $(ps | grep -v grep | grep $service | wc -l) > 0 ))
then
????? # code if already running
else
$service start # code if not started
fi
Look at the script I've got from @vgaetera His script is working perfectly, as my vpn goes down, it restarts. So far so good.
I just want to understand wat the crontab line * * * * * means, because it's working.
It doesn't say check every minute 1 * * * * or every day at 12PM * 12 * * *