Scheduling tasks with systemd timers
Flatcar Container Linux uses systemd timers (cron replacement) to schedule tasks. Here we will show you how you can schedule a periodic job.
Let’s create an alternative for this crontab job:
|
|
Timers work directly with services’ units. So we have to create /etc/systemd/system/date.service first:
|
|
Then we have to create timer unit with the same name but with *.timer suffix /etc/systemd/system/date.timer:
|
|
This config will run date.service every 10 minutes. You can also list all timers enabled in your system using systemctl list-timers command or systemctl list-timers --all to list all timers. Run systemctl start date.timer to enable timer.
You can also create timer with different name, i.e. task.timer. In this case you have specify service unit name:
|
|
Butane Config
Here you’ll find an example Butane Config demonstrating how to install systemd timers:
|
|
Further reading
If you’re interested in more general systemd timers feature, check out the full documentation .