Page 1 of 1

systemd timers

Posted: Mon May 21, 2018 9:49 am
by bluebell
I noticed an xrun while the PC seemed to do nothing. But in my Xubuntu 16.04 there was a bad systemd timer that cleaned up tempfiles and did some I/O 30 Minutes after boot. Bad.

Fortunately you can change it.

List the timers: sudo systemctl list-timers

You can stop and disable some (the apt stuff) but you can't disable systemd-tmpfiles-clean.timer permanently.
So you have to edit it. I did:

sudo systemctl edit systemd-tmpfiles-clean.timer

and filled the file with:

[Timer]
OnBootSec=
OnBootSec=1min
OnUnitActiveSec=

Now the tempfiles are cleaned immediately after boot. That's ok for me. Note that the settings with no value (OnBootSec=) are important because else everything you write in the file is added to the existing definition. That's not what you want.

EDIT:
On closer investigation it showed out that this documented behaviour does NOT work. Settings with no value produce an error message.

So I stayed with making changes in the main file and protect it against changes:

vi /lib/systemd/system/systemd-tmpfiles-clean.timer
chattr +i /lib/systemd/system/systemd-tmpfiles-clean.timer

EDIT2:
Even better:

systemctl mask systemd-tmpfiles-clean.timer
systemctl enable systemd-tmpfiles-clean

The service is defined as one-shot and doesn't need a timer to be started at boot time.