You are not logged in.

#1 2016-06-19 20:09:55

Sanjeev K Sharma
Member
Registered: 2013-08-14
Posts: 71

[Solved] systemd timers do not auto start as user services

the timer awar has been enabled - I've stripped the files down

file awar.service

[Unit]

[Service]
  Type=simple

  # LAST STATEMENT MAY NOT FORK
  ExecStart=/home/sam/bin/awar

file awar.timer

[Unit]

[Timer]
  Unit=awar.service

  OnUnitInactiveSec=10s
  AccuracySec=1s

[Install]
  #WantedBy=multi-user.target
  WantedBy=timers.target

on startup the timer's status looks like this

$ systemctl --user list-timers --all  --full
NEXT LEFT LAST PASSED UNIT       ACTIVATES
n/a  n/a  n/a  n/a    awar.timer awar.service

. timers listed.

this does not work - supposedly you're not supposed to start the service file (I am cd'd to the directory holding these files) - this leaves the above timers list unchanged from the above

$systemctl --user restart awar.timer --all  --full

this does work - though you're not supposed to start the service file

$systemctl --user restart awar.service --all  --full
$systemctl --user list-timers --all  --full
NEXT                         LEFT    LAST                         PASSED  UNIT       ACTIVATES
Sun 2016-06-19 16:06:06 EDT  15s ago Sun 2016-06-19 16:06:06 EDT  14s ago awar.timer awar.service

1 timers listed.

EDIT: I didn't show the actual status  - here's another timer stuck at startup

$systemctl --user status grip.*
● grip.service - grip
   Loaded: loaded (/home/sam/.config/systemd/user/grip.service; static; vendor preset: enabled)
   Active: inactive (dead)

● grip.timer - grip
   Loaded: loaded (/home/sam/.config/systemd/user/grip.timer; enabled; vendor preset: enabled)
   Active: active (elapsed) since Sun 2016-06-19 15:44:27 EDT; 26min ago

Jun 19 15:44:27 samain systemd[1525]: Started grip.
Jun 19 15:44:27 samain systemd[1525]: Starting grip.
$systemctl --user list-timers --all  --full
NEXT                         LEFT     LAST                         PASSED   UNIT       ACTIVATES
n/a                          n/a      n/a                          n/a      grip.timer grip.service

1 timers listed.

Last edited by Sanjeev K Sharma (2016-06-19 20:48:02)

Offline

#2 2016-06-19 20:21:55

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

Re: [Solved] systemd timers do not auto start as user services

I don't know if your other timers are similar, but in the one you showed, the only trigger is OnUnitInactiveSec. If the unit (the service) has never been activated (and I think this is a per-boot thing unless you set Persistent=true), it makes sense that this will never be triggered -- until you start the service explicitly.

Last edited by Raynman (2016-06-19 20:23:10)

Offline

#3 2016-06-19 20:47:40

Sanjeev K Sharma
Member
Registered: 2013-08-14
Posts: 71

Re: [Solved] systemd timers do not auto start as user services

Raynman wrote:

I don't know if your other timers are similar, but in the one you showed, the only trigger is OnUnitInactiveSec. If the unit (the service) has never been activated (and I think this is a per-boot thing unless you set Persistent=true), it makes sense that this will never be triggered -- until you start the service explicitly.

coolness, thanks - I just did not grok that piece

either of these work

Persistent=true
OnBootSec=150

Offline

Board footer

Powered by FluxBB