I am trying to create some systemd units that are supposed to start scripts at certain intervals. With Cron, I used an expression like 0 3 */7 * * to start a job every 7 days at 3 a.m. That worked great. With OnCalendar, I have no idea how to implement “every 7 days”. Or can I use OnUnitActiveSec here? Additional problem: The computer is not always on at the specified time. The job should therefore be repeated as soon as the computer is available again. I have set Persistent=true for this purpose. However, I suspect that OnUnitActiveSec is reset every time I restart the computer. Or does OnUnitActiveSec refer to the time when the unit was activated with systemctl enabled test.timer?

  • oranki@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    3
    ·
    7 days ago

    Would something like

    OnCalendar=Wed *-*-* 03:00:00
    

    Technically not the same as every 7 days, instead it’s every Wednesday.

    • MoLoPoLY@discuss.tchncs.deOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      7 days ago

      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.