A systemd unit to kill a daemon on loop

tracker-store leaks memory on my system, and after approximately 1 day of uptime, it'll leak everything and send my system into a lockup. The kernel out-of-memory (OOM) killer isn't going to do anything, and I'm not sure if earlyoom is going to help either. This means the simplest solution is just going to be:

while true; do
  pkill tracker-store
  sleep 3h

If I had to do this with Firefox or Chrome, this would be a bit too extreme, but since tracker-store is only supposed to run in the background anyway, I don't mind (or care) if it's getting killed.

So, also wanting to learn systemd timers, I wrote a timer that does what the above script does.

The service file (~/.config/systemd/user/kill-tracker.service) that the timer will fire:

Description=Kill tracker-store

ExecStart=/usr/bin/pkill tracker-store
SuccessExitStatus=0 1

Exit status 1 from pkill means the process couldn't be found.

The timer (~/.config/systemd/user/kill-tracker.timer):

Description=Kill tracker-store



Then run systemctl --user enable --now kill-tracker.timer to enable and start the timer.