View previous topic :: View next topic |
Author |
Message |
equaeghe l33t
Joined: 22 Feb 2005 Posts: 649
|
Posted: Sun Apr 10, 2016 4:41 pm Post subject: [solved] systemd user timer-triggered service is not running |
|
|
I am trying to run user backup scripts using systemd's monotonic timer functionality (the user is root in this case):
Code: | # cat rsnapshot-hourly@.timer
[Unit]
Description=hourly rsnapshot backup to %i
RefuseManualStart=no
RefuseManualStop=no
[Timer]
OnUnitInactiveSec=1h
Unit=rsnapshot@%i.service
[Install]
WantedBy=default.target |
Code: | # cat rsnapshot@.service
[Unit]
Description=rsnapshot backup %i
RefuseManualStart=no
RefuseManualStop=yes
[Service]
Type=oneshot
EnvironmentFile=/root/.config/systemd/user/%i.env
ExecStart=/usr/local/bin/backup+mount.sh $LOCATION $PERIODICITY |
Code: | # cat internalhourly.env
LOCATION = internal
PERIODICITY = hourly |
I've checked that running
Code: | # systemctl --user start rsnapshot@internalhourly.service |
works.
I've added the timers and get
Code: | # list --user list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Sun 2016-04-10 18:48:26 CEST 15min left n/a n/a rsnapshot-hourly@internalhourly.timer rsnapshot@internalhourly.service
Sun 2016-04-10 18:51:16 CEST 18min left n/a n/a rsnapshot-hourly@external-hourly.timer rsnapshot@external-hourly.service
n/a n/a n/a n/a rsnapshot-daily@external-daily.timer rsnapshot@external-daily.service
n/a n/a n/a n/a rsnapshot-daily@externaldaily.timer rsnapshot@externaldaily.service
n/a n/a n/a n/a rsnapshot-daily@internaldaily.timer rsnapshot@internaldaily.service
n/a n/a n/a n/a rsnapshot-hourly@externalhourly.timer rsnapshot@externalhourly.service
n/a n/a n/a n/a rsnapshot-monthly@external-monthly.timer rsnapshot@external-monthly.service
n/a n/a n/a n/a rsnapshot-monthly@externalmonthly.timer rsnapshot@externalmonthly.service
n/a n/a n/a n/a rsnapshot-monthly@internalmonthly.timer rsnapshot@internalmonthly.service
n/a n/a n/a n/a rsnapshot-weekly@external-weekly.timer rsnapshot@external-weekly.service
n/a n/a n/a n/a rsnapshot-weekly@externalweekly.timer rsnapshot@externalweekly.service
n/a n/a n/a n/a rsnapshot-weekly@internalweekly.timer rsnapshot@internalweekly.service
12 timers listed.
Pass --all to see loaded but inactive timers, too. |
where the first two NEXT and LEFT values appeared after a manual service start.
How do I fix the unit files or my configuration to make this work?
Last edited by equaeghe on Wed Apr 13, 2016 9:34 pm; edited 3 times in total |
|
Back to top |
|
|
equaeghe l33t
Joined: 22 Feb 2005 Posts: 649
|
Posted: Sun Apr 10, 2016 5:51 pm Post subject: systemd user timer-triggered service is'nt running |
|
|
Ok, I figured it out myself:
equaeghe wrote: |
[Timer]
OnUnitInactiveSec=1h
[/code]
[code] |
The unit must first have been active! Running them manually once is enough to get things going. |
|
Back to top |
|
|
equaeghe l33t
Joined: 22 Feb 2005 Posts: 649
|
Posted: Mon Apr 11, 2016 7:57 pm Post subject: Re: systemd user timer-triggered service is'nt running |
|
|
equaeghe wrote: | Ok, I figured it out myself:
equaeghe wrote: |
[Timer]
OnUnitInactiveSec=1h
[/code]
[code] |
The unit must first have been active! Running them manually once is enough to get things going. |
But this is only true until the next shutdown/reboot... So my problem isn't fixed yet. I thought the monotonic timers' main advantage was that they continued working even beyond reboots? |
|
Back to top |
|
|
equaeghe l33t
Joined: 22 Feb 2005 Posts: 649
|
Posted: Wed Apr 13, 2016 9:33 pm Post subject: Re: systemd user timer-triggered service is'nt running |
|
|
equaeghe wrote: | I thought the monotonic timers' main advantage was that they continued working even beyond reboots? |
My conclusion is that this isn't the case... I'll workaround suboptimally using OnCalendar. |
|
Back to top |
|
|
|