[clug] systemctl - timer keeps cancelling, I think

Tony Lewis tony at lewistribe.com
Thu Sep 8 02:24:47 UTC 2022


On 7/9/22 21:02, Tony Lewis via linux wrote:
> Hi Chris,
>
> It's not a oneshot, and in fact in typical fashion I think I might 
> have fixed it.  I went through the stop, disable, enable, start loop 
> and it might be working now.  I have it on a daily cycle so will check 
> tomorrow before extending it out a couple of days.

Yeah nah, didn't work.

I've now done the loginctl command, and will try again.  If that fails, 
I'll try setting it to Type=oneshot.

In the meantime, this was last night, showing the timer had a date to 
fire next:

email at host:~/.config/systemd/user$ systemctl --user --all list-timers
NEXT                         LEFT     LAST 
                         PASSED       UNIT                  ACTIVATES
Thu 2022-09-08 20:50:32 AEST 23h left Wed 2022-09-07 17:33:05 AEST 3h 
28min ago imapsync-emails.timer imapsync-emails.service

And this is it now:

email at host:~$ systemctl --user --all list-timers
NEXT LEFT LAST                         PASSED  UNIT 
                  ACTIVATES
n/a  n/a  Wed 2022-09-07 17:33:05 AEST 18h ago imapsync-emails.timer 
imapsync-emails.service

Here's the .service file:

email at host:~$ cat ~/.config/systemd/user/imapsync-emails.service
[Unit]
Description=Synchronise emails and then send them to borg

[Service]
Type=simple
ExecStart=/home/email/bin/imapsync-and-borg

[Install]
WantedBy=multi-user.target

And the .timer:

email at host:~$ cat ~/.config/systemd/user/imapsync-emails.timer
[Unit]
Description=Backup profile stuff onto remote server on local network

[Timer]
OnUnitActiveSec=1d
AccuracySec=10m
RandomizedDelaySec=43200
Persistent=true

[Install]
WantedBy=timers.target

And here are the statuses of them:

email at host:~$ systemctl --user status imapsync-emails.timer
●imapsync-emails.timer - Backup profile stuff onto remote server on 
local network
     Loaded: loaded 
(/home/email/.config/systemd/user/imapsync-emails.timer; enabled; vendor 
preset: enabled)
     Active: active (elapsed)since Thu 2022-09-08 12:07:18 AEST; 3min 
53s ago
    Trigger: n/a
   Triggers: ● imapsync-emails.service

Sep 08 12:07:18 host systemd[137276]: Started Backup profile stuff onto 
remote server on local network.
email at host:~$ systemctl --user status imapsync-emails.service
● imapsync-emails.service - Synchronise emails and then send them to borg
     Loaded: loaded 
(/home/email/.config/systemd/user/imapsync-emails.service; enabled; 
vendor preset: enabled)
     Active: inactive (dead)
TriggeredBy: ●imapsync-emails.timer

Sep 07 17:58:10 host imapsync-and-borg[135816]: Number of files: 192697
Sep 07 17:58:10 host imapsync-and-borg[135816]: Utilization of max. 
archive size: 0%
Sep 07 17:58:10 host imapsync-and-borg[135816]: 
------------------------------------------------------------------------------
Sep 07 17:58:10 host imapsync-and-borg[135816]: 
                        Original size      Compressed size 
    Deduplicated size
Sep 07 17:58:10 host imapsync-and-borg[135816]: This archive: 
               19.71 GB             15.24 GB              8.25 MB
Sep 07 17:58:10 host imapsync-and-borg[135816]: All archives: 
                2.55 TB              2.00 TB             33.93 GB
Sep 07 17:58:10 host imapsync-and-borg[135816]: 
                        Unique chunks         Total chunks
Sep 07 17:58:10 host imapsync-and-borg[135816]: Chunk index: 
                  453119             29265237
Sep 07 17:58:10 host imapsync-and-borg[135816]: 
------------------------------------------------------------------------------
Sep 07 17:58:10 host systemd[134804]: imapsync-emails.service: Succeeded.

So, I'm open to more thoughts and suggestions.  Note that this is a 
guest LXC container, running Ubuntu 20.04.4

Tony


> On 7/9/22 18:24, Chris Smart via linux wrote:
>> Is your service of type oneshot? I.e.
>>
>> [Service]
>> Type=oneshot
>>
>> What's your timer set to? E.g.
>>
>> [Timer]
>> OnBootSec=
>> OnCalendar=Mon *-*-* 00:00:00
>> Persistent=true
>>
>> For an example, 
>> seehttps://blog.christophersmart.com/2021/05/23/auto-update-pi-hole-with-systemd-timer/ 
>>
>> Also, do you need to enable linger for your user?
>>
>> sudo loginctl enable-linger "${USER}"
>>
>> -c
>>


More information about the linux mailing list