4

I have a systemd timer that I would like to run every weekday morning at 5:30am. Here's the .timer file:

[Unit]
Description=My Cool Timer

[Timer]
OnCalendar=Mon-Fri 05:30:00

[Install]
WantedBy=timers.target

I set up this timer last night, and it fired this morning right on schedule. However, checking on its status shows that it's next scheduled firing (LEFT) is 8 hours ago:

boatzart@machine: sudo systemctl list-timers myCoolTimer.timer
NEXT                         LEFT     LAST                         PASSED             UNIT                         ACTIVATES
Thu 2016-09-01 05:30:00 PDT  8h ago   Thu 2016-09-01 05:30:00 PDT  8h ago             myCoolTimer.timer          myCoolTimer.service

I'm not sure if it matters, but the associated .service file is Type=forking.

How do I get my timer to actually repeat?

  • And what is the status of the associated service? – Michael Hampton Sep 1 '16 at 21:39
  • It's currently active (running). The service is a bash script that tears down, and then rebuilds a tmux session that is running a bunch of stuff on a server. – rcv Sep 1 '16 at 21:41
3

I think you missed this bit of the documentation:

Note that in case the unit to activate is already active at the time the timer elapses it is not restarted, but simply left running.

The timer does nothing at the next scheduled time, because the service is already running.

| improve this answer | |
  • I suppose what I really want is for the timer to restart the service, instead of just starting it. Do you know if this is possible? – rcv Sep 1 '16 at 22:25
  • @Boatzart For a properly designed service, you should not have to restart it on a timer, or for any reason other than a configuration change. What is actually going on? – Michael Hampton Sep 2 '16 at 1:08
  • What's going on is a hack on a hack. My team has a shared tmux session on a remote server that we can log into to maintain some tasks. For various reasons, this session needs to be restarted every morning at 5:30. I just got this working - my solution was to make a separate sharedSessionStop.service and sharedSessionStart.service on separate timers to tear down and rebuild that shared session. – rcv Sep 2 '16 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.