How to run a script every 10 minutes on VyOS

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

  1. Enter configuration mode:
configure
  1. 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
  1. 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/bash or #!/bin/vbash)
  • If your script needs to run VyOS operational commands, use /bin/vbash as 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.

Leave a Reply