Hello,
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
Also it would be nice to have some examples on the wiki @
Task Scheduler — VyOS 1.4.x (sagitta) documentation
Version: VyOS 1.3.2
Release train: equuleus
Any ideas on why this is failing?
Thanks
-Nathan
What are the permissions on the script? It’s it set to executable? chmod +x /config/scripts/restartvpn.sh
As mentioned by zero1three013, make sure your script is executable.
1 Like
and please update your VyOS version. 1.3.2 is almost as old as me… 
2 Likes
That was it, I just needed to set to executable. Thanks all
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.
1 Like
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
connections=$(sudo /opt/vyatta/bin/vyatta-op-cmd-wrapper show conntrack table ipv4 | awk ‘$2 ~ /^(10.10.10.1|10.20.10.1)/ && $6 ~ /ES/’)
If no connections are found, restart VPN
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’