TheHighFlyingBirds
New Around Here
Hi,
First post and novice, so go easy on me.
I'm using an ASUS RT-AX86U pro with merlin 3004.388.4 FW. I am trying to get a cron job running to check a VPN connection, and re-instate it if it has failed.
I have enabled the "enable jffs custom scripts and config" option.
I have created a script > vpncheck.sh which is located in /jffs/scripts and runs fine manually. Script is:
When I run it manually it updates the output.txt file accordingly, and if the VPN is down, it reconnects it.
I have also created a services-started file, which contains the following:
I have applied chmod 777 to all three files in scripts folder, such that they are all -rwxrwxrwx
I then added the cron task using the following:
When I check the cron file in /var/spool/cron/crontabs/{my username} it shows up, with the output being:
The task remains after a reboot. However, it just doesn't seem to run, as the output.txt file does not change and if I turn off the vpn it does not restart it. I cannot see any mention of cron in syslog.log, and doing a search of the other tasks also draws a blank.
I have even tried creating a simple cron task using the same approach as above and still nothing.
Can anyone help?
Thanks in advance.
First post and novice, so go easy on me.
I'm using an ASUS RT-AX86U pro with merlin 3004.388.4 FW. I am trying to get a cron job running to check a VPN connection, and re-instate it if it has failed.
I have enabled the "enable jffs custom scripts and config" option.
I have created a script > vpncheck.sh which is located in /jffs/scripts and runs fine manually. Script is:
Code:
#!/bin/sh
# check state of VPN client1
#if = 0, VPN is down
#if != 0, VPN is running
if [[ $(nvram get vpn_client1_state) != 0 ]]
then
echo "VPN Running - test last run at $(date)" | tee output.txt
elif [[ $(nvram get vpn_client1_state) == 0 ]]
then
service start_vpnclient1
sleep 10
if [[ $(nvram get vpn_client1_state) != 0 ]]; then
echo "VPN Restarted Successfully - test run at $(date)" | tee output.txt
else
echo "VPN Failed - test last run at $(date)" | tee output.txt
fi
fi
I have also created a services-started file, which contains the following:
Code:
#!/bin/sh
# This cript get called after all other system services
# have been started at boot on router
# ---------------------------------------------------------
# cron job to run vpn check script - this ensures cron task is started following reboot
cru a vpncheck "*/1 * * * * /jffs/scripts/vpncheck.sh"
I have applied chmod 777 to all three files in scripts folder, such that they are all -rwxrwxrwx
I then added the cron task using the following:
Code:
cru a vpncheck "*/1 * * * * /jffs/scripts/vpncheck.sh"
When I check the cron file in /var/spool/cron/crontabs/{my username} it shows up, with the output being:
Code:
*/1 * * * * /jffs/scripts/vpncheck.sh #vpncheck#
*/2 * * * * /etc/openvpn/server1/vpn-watchdog1.sh #CheckVPNServer1#
46 9 */7 * * service restart_letsencrypt #LetsEncrypt#
The task remains after a reboot. However, it just doesn't seem to run, as the output.txt file does not change and if I turn off the vpn it does not restart it. I cannot see any mention of cron in syslog.log, and doing a search of the other tasks also draws a blank.
I have even tried creating a simple cron task using the same approach as above and still nothing.
Can anyone help?
Thanks in advance.