To run a script every 10 minutes on VyOS, you should use the VyOS task scheduler. Here’s how to configure it:
Using VyOS Task Scheduler
- Enter configuration mode:
configure
- Set up the task scheduler:
set system task-scheduler task dns-update executable path /home/vyos/dns-vyos.sh
set system task-scheduler task dns-update interval 10m
- Commit and save the configuration:
commit
save
exit
Verify the Configuration
Check that your task is configured correctly:
show system task-scheduler
Important Notes
- Make sure your script has execute permissions:
chmod +x /home/vyos/dns-vyos.sh
- The script should include a proper shebang line (e.g.,
#!/bin/bashor#!/bin/vbash) - If your script needs to run VyOS operational commands, use
/bin/vbashas the interpreter
Alternative: Traditional Cron (Not Recommended)
While you could use standard cron (crontab -e), it’s not recommended on VyOS because:
- Changes won’t persist through configuration backups
- They may be lost during system updates
- The task scheduler is the VyOS-native way to handle scheduled tasks
The task scheduler approach ensures your scheduled tasks are part of your VyOS configuration and will persist properly.