I am trying to use task schedule to accomplish a very simple task, restart vpn services every hour. I get an error when trying to use task scheduler . Commands, script and error below.
set system task-scheduler task restartvpn executable path ‘/config/scripts/restartvpn.sh’
set system task-scheduler task restartvpn interval ‘60m’
script
#!/bin/vbash source /opt/vyatta/etc/functions/script-template run restart vpn
error
Invalid task restartvpn: file /config/scripts/restartvpn.sh does not
exist or is not executable
One last note, make sure you add exit to the end of your script. Otherwise you’ll get a large number of fuse mountpoints that can eventually lock up your config unless you reboot.
I ended up using bash and AWK to check the status of the connection table and restart vpn only if there was not an established connection to the desired endpoints
#!/bin/bash
Check for established connections to specific IP addresses
if [ -z “$connections” ]; then
echo “No established connections found to 10.10.10.1 or 10.20.10.1. Restarting VPN…”
sudo /opt/vyatta/bin/vyatta-op-cmd-wrapper restart vpn
else
echo “Established connection(s) found:”
echo “$connections”
fi
sudo chmod +x /config/scripts/restart-vpn.sh
exit
configure
set system task-scheduler task restartvpn executable path ‘/config/scripts/restart-vpn.sh’
set system task-scheduler task restartvpn interval ‘1’