This might interest you. https://crontab.guru/
Linux Questions
Linux questions Rules (in addition of the Lemmy.zip rules)
- stay on topic
- be nice (no name calling)
- do not post long blocks of text such as logs
- do not delete your posts
- only post questions (no information posts)
Tips for giving and receiving help
- be as clear and specific
- say thank you if a solution works
- verify your solutions before posting them as facts.
Any rule violations will result in disciplinary actions
Check the man pages, starting with man systemd.time
OnCalendar is calendar-based, not interval-based.
Use a monotonic timer with OnUnitActiveSec=7d plus Persistent=true .
This is not quite the same as your cron, because it can drift the day of ghe weak.
And no, it does not reset just because you reboot.
It seems that this doesn't work as expected. Please see my new post from today. I have found also the following issue https://github.com/systemd/systemd/issues/3107. According to this, a monotonic timer doesn't survive a reboot or power off. Please correct me, if I'm wrong.
If I understand this correctly, only a onCalendar type can be used here. That's a little bit annoying, but as of yet, I haven't found a way around this.
Shifting the day of the week is totally fine, since i only care about days between the job executions. Many thx, then i try my luck with this.
Note that you can use systemctl list-timers to see all active timers including when they will next run and when they last ran. This is very useful for seeing if you have set things up correctly.
There are multiple ways to do this as well. You can do
OnCalendar=Sun 03:00
Persistent=true
To run every Saturday at 3am. And will run immediately when activated if the last time was skipped due to the system being off. Think that is the closest to your cron job.
You can also
OnCalendar=weekly
Persistent=true
If you don't care when it will run. This is equivalent to Mon *-*-* 00:00:00.
Ahh even more possibility's. Many thx.
Why does it say "Sun" if it runs on Saturday?
Would something like
OnCalendar=Wed *-*-* 03:00:00
Technically not the same as every 7 days, instead it's every Wednesday.
OK. I think 7 day was a slightly misleading schedule :-) My bad. But yes, you are right, for 7 days, this will work fine. But i think OnUnitActiveSec=7d is more flexible, when i change this to 12 days, 9 days and so on... I should learn to be more precise in my questions. Sorry.