[systemd-devel] How to schedule a resource consuming service

Fabrice Salvaire fabrice.salvaire at orange.fr
Sat Feb 2 13:50:48 UTC 2019


Dear all,

In Fedora mlocate (updatedb) service is setup like this

--------------------------------------------------------------------------

 > cat /usr/lib/systemd/system/mlocate-updatedb.service
[Unit]
Description=Update a database for mlocate

[Service]
ExecStart=/usr/libexec/mlocate-run-updatedb
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7

PrivateTmp=true
PrivateDevices=true
PrivateNetwork=true
ProtectSystem=true

--------------------------------------------------------------------------

 > cat /usr/lib/systemd/system/mlocate-updatedb.timer
[Unit]
Description=Updates mlocate database every day

[Timer]
OnCalendar=daily
AccuracySec=24h
Persistent=true

[Install]
WantedBy=timers.target
--------------------------------------------------------------------------

Unfortunately it saturates the IO after the boot when the machine was 
not running at midnight (not sure ???), see 
https://bugzilla.redhat.com/show_bug.cgi?id=1282232

This is painful when we want to use the machine asap, for a quite full 
500 GB disk, it hangs during several minutes.  I encountered an unusable 
machine during more than 10 min due to mlocate and/or gnome indexer 
saturating IO and package cache update saturating a low ADSL connexion.

I noticed IOSchedulingClass=2 could be set to "idle", maybe it would 
improve.

I also read 
https://www.freedesktop.org/software/systemd/man/systemd.timer.html but 
I don't understand if there is a way to prevent to run the service 
during 1h after boot.

Well a way to run theses services during idle time.

Cheers,

Fabrice





More information about the systemd-devel mailing list