SystemD timers
Hey. I set up a systemD timer for a service that is activated from Monday to Friday at 09:00. It is not set to run on weekend days, but I have set the “persistent” option to true, so if I power up the machine after that time, the service is executed asap.
Quick question: if I don’t power up the machine at all on Friday, but I do on Saturday, will the timer start the application?
About this post
- Posted
- Archived
- Score
- 5 · 74% up
- Kind
- Text
- ID
- kxsin5
7 comments
Are these easier than cronjobs?
No. You have to create both a timer file and possibly a service file. Then the timer needs to started and enabled.
But timers are more powerful, flexible and consistent with the rest of systemd, so I prefer them.
IMO yes they are easier than cronjobs, and have much more advanced features like being able to tell if the timer should have ran when the computer was off built into the system, and massively higher accuracy for timers than what cron is capable of. Cron is limited to 60 seconds afaik, where systemd timers can have microsecond accuracy. It also has a lot more features as well, but those are some cool ones I figured would be worth mentioning.
Deleted before we saved it.
They are harder if you want to "run this executable on a timer without duplicate detection, proper logging, automatic restarts and everything else". Implementing any of these in cronjob is a major PITA, but just a line in systemd service/timer file.
From the description in the documentation, I would expect so. It just checks if the timer would have run while the system was off, not whether it would run anyway that day.
Yes it will still run the timer, so long as you have persistent set to true.