It sets a max time a service is allowed to stay running. I just went and edited those 2 lines, and set it to 120 (seconds):
● plasma-plasmashell.service - KDE Plasma Workspace
Loaded: loaded (/etc/xdg/systemd/user/plasma-plasmashell.service; disabled; preset: enabled)
Active: active (running) since Wed 2022-11-16 17:36:04 CET; 12s ago
Until: Wed 2022-11-16 17:38:04 CET; 1min 47s left
Main PID: 2380 (plasmashell)
Memory: 214.2M
And after 120 seconds:
● plasma-plasmashell.service - KDE Plasma Workspace
Loaded: loaded (/etc/xdg/systemd/user/plasma-plasmashell.service; disabled; preset: enabled)
Active: active (running) since Wed 2022-11-16 17:38:05 CET; 2s ago
Until: Wed 2022-11-16 17:40:05 CET; 1min 57s left
Main PID: 2492 (plasmashell)
Tasks: 30 (limit: 9514)
Memory: 212.3M
EDIT:
So to recap what we learned, hopefully:
- Copy
/usr/lib/systemd/user/plasma-plasmashell.service
into/etc/systemd/user/
- Edit/add:
Restart=always
RuntimeMaxSec=1h
- Reload daemons.
- Restart service.
- [Optionally add
RuntimeRandomizedExtraSec=<some value>
so you’ll never know when exactly restart is coming. More thrill. ]
EDIT 2:
As @TriMoon noted in a post below, there is a more correct way to do it. So read his post and/or check: systemd - ArchWiki.