I generally like some things that syatemd gives, but is there an easier way to create timed automations with systemd timers?
with cron, its just a single line with the recurrence pattern and the command. with systemd, you have to create a timer unit file with several lines, a service unit file with several lines, put them in the right directory, reload systemd, enable the timer. timers are not difficult, but much more convoluted than the crontab.
helix@feddit.org 1 week ago
here’s a single line for you which creates a one-shot service+timer in one go, suspending the system in 4 hours:
If you want it to run repeatedly, simply replace
–on-activewith–on-calendar=“*-*-* 04:00:00”for example.WhyJiffie@sh.itjust.works 1 week ago
thank you. this creates it, but is there a way to view or edit its current configuration in a similar format? and this is not persisted, is it?
helix@feddit.org 6 days ago
If you inspect the generated timer you see the same format in the OnCalendar line.
What do you mean by persisted? The service and timer will both be there as long as the timer doesn’t end. Which it won’t in my example.
If you want to copy it for later reference, you can simply copy the files.
WhyJiffie@sh.itjust.works 6 days ago
but without the command
I mean saved to a file so that it will still be there after reboot