You are not logged in.

#1 2014-04-02 08:45:35

Osiris
Member
Registered: 2003-01-18
Posts: 153
Website

systemd timers not working

Hello,
I try to set up a simple systemd timer as user. My configuration so far is:

florian@horus-mac ~ % cat .config/systemd/user/helium-sync.timer  
[Unit]
Description=Timer to sync home with helium

[Timer]
OnUnitActiveSec=2min

florian@horus-mac ~ % cat .config/systemd/user/helium-sync.service
[Unit]
Description=Sync home with helium

[Service]
Nice=10
ExecStart=/home/florian/software/bin/helium-sync.sh

helium-sync.sh at this time is just a simple script putting a timestamp in my ~. This is exactly also what "systemctl --user start helium-sync" does, the service seems to work. But the timer never fires:

florian@horus-mac ~ % systemctl --user status helium-sync.timer  
● helium-sync.timer - Timer to sync home with helium
   Loaded: loaded (/home/florian/.config/systemd/user/helium-sync.timer; static)
   Active: active (elapsed) since Mi 2014-04-02 10:15:13 CEST; 21min ago

Apr 02 10:15:13 horus-mac systemd[256]: Starting Timer to sync home with helium.
Apr 02 10:15:13 horus-mac systemd[256]: Started Timer to sync home with helium.

florian@horus-mac ~ % systemctl --user status helium-sync.service
● helium-sync.service - Sync home with helium
   Loaded: loaded (/home/florian/.config/systemd/user/helium-sync.service; static)
   Active: inactive (dead)

I also tried added an explicit "Unit=helium-sync.service" to the [Timer] section. (which should according to the docs unecessary, since .timer and .service file have the same name)

Anyone know what could be wrong here?

Thanks!

Offline

#2 2014-04-02 10:12:01

brain0
Developer
From: Aachen - Germany
Registered: 2005-01-03
Posts: 1,382

Re: systemd timers not working

Look further at the journal (journalctl -b --user). It says that the timer elapsed, so the service should have run.

Offline

#3 2014-04-02 10:21:39

Osiris
Member
Registered: 2003-01-18
Posts: 153
Website

Re: systemd timers not working

Negative, nothing but

Apr 02 12:15:32 horus-mac systemd[256]: Starting Timer to sync home with helium.
Apr 02 12:15:32 horus-mac systemd[256]: Started Timer to sync home with helium.

Offline

#4 2014-04-02 11:03:44

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: systemd timers not working

Osiris wrote:

Negative, nothing but

Apr 02 12:15:32 horus-mac systemd[256]: Starting Timer to sync home with helium.
Apr 02 12:15:32 horus-mac systemd[256]: Started Timer to sync home with helium.

You rebooted? Because in your first post the time was 10:15. And you're only using OnUnitActiveSec, which defines a timer relative to when the corresponding service was last activated, so it's not going to start on its own. You said the script worked when manually starting the service. At that point the service is activated, so I would expect the timer to be triggered 2 minutes later (and again 2 minutes later etc.). But if the service unit is never activated (after a reboot) the timer shouldn't do anything. To change that you would add OnBootSec or OnStartupSec.

Offline

#5 2014-04-02 11:33:40

Osiris
Member
Registered: 2003-01-18
Posts: 153
Website

Re: systemd timers not working

Ok, I didn't know that OnUnitActiveSec never activates the unit itself for the first time. I added OnActiveSec=2min, know it works.

Apr 02 13:29:14 horus-mac systemd[256]: Starting -.slice.
Apr 02 13:29:14 horus-mac systemd[256]: Created slice -.slice.
Apr 02 13:29:14 horus-mac systemd[256]: Starting Sync home with helium...
Apr 02 13:29:14 horus-mac systemd[256]: Started Sync home with helium.

and also:

[Install]
WantedBy=default.target

for enabling.

Thanks!

Offline

Board footer

Powered by FluxBB