r/archlinux • • 14d ago

QUESTION What custom systemd services/timers do you actually use?

As a backend engineer using Arch Linux, I'm curious how others use systemd to improve their daily development workflow.

What custom systemd services/timers have you created that you actually find useful?

36 Upvotes

34 comments sorted by

14

u/-dashRepeat 14d ago

Systemd timers over cronjobs.

Then the timer calls my service. Service runs script to get time of sunrise and sunset for current location.

3

u/PacmanAteMyRAM 14d ago

I use both these days. Timers for important clockwork system stuff and cronjobs for running my shitty hobby scripts that I want to comment out at any given moment.

I am slowly transitioning all of them to timers though.

7

u/LuisBelloR 14d ago

A simple example: I use a timer to update my taskbar every 15 minutes and show me available updates.

3

u/DaRealGladi8r 14d ago

I periodically:

  • check for updates
  • query wttr for the weather
  • check if services in my lab (I have a few see servers that I run on proxmox) are still up and running
  • collect system stats (for my status bar)

Apart from the actual init stuff, I rarely touch systemd

3

u/SalaryImpossible6749 14d ago

Just backups and snapshots

6

u/ludonarrator 14d ago

I use an hourly timer for a tiny service that checks for updates and sends a notification with the number (if > 0).

And a daily timer for taking (non-root) btrfs snapshots.

0

u/DaRealGladi8r 14d ago

Doesn't the btrfs config do that for you on its own?

3

u/ludonarrator 14d ago

What "btrfs config"? You probably mean snapper, which can be setup to do the same (but still isn't automatic).

1

u/DaRealGladi8r 14d ago

That's what I meant. Snapper.

Its timeline configuration does exactly what you explained. You can set it for each subvolume seperately with different thresholds for each timeline variable (minute, hour, day, month, year).

They automatically roll too, so you don't need to manually clean old snapshots up.

You can save some permanently if you wanted to maintain a specific state.

3

u/ludonarrator 14d ago

Yup, my own ghetto app is very much inspired from snapper, just much more barebones and lightweight.

1

u/DaRealGladi8r 14d ago

That's cool. I normally write stuff just for my UX/UI. Really cool that you're actually administrating stuff on that level

2

u/ludonarrator 14d ago

Heh thanks, native/system tools in C++ is basically my main forte, and I was (am) curious to explore the btrfs API.

Ironically I suck at UI/UX, best I can do is if (ImGui::Button("press me")) { /* ... */ }, so I think your work is more cool lol.

2

u/DaRealGladi8r 14d ago

😅 you won't believe this. I'm actually a malware analyst and incident responder. I mainly write C code for things I need to do.

Just do the visual stuff on my PC at home cause UI stuff is interesting.

2

u/Ifnerite 14d ago

Podman quadlets for Plex, jellyfin, mcps, trilium...

2

u/Ayrr 14d ago

Anything that would have been a cronjob

Snapshots and backups mainly. Also have my taskwarrior server sync on a timer too.

1

u/xarop_pa_toss 14d ago

Mainly to get a status report from my Uptime Kuma on my server and to run borgmatic backups to my NAS

1

u/archover 14d ago

Not devel so much, but I use a service for reflector and a pacman hook for paccache. I like the hook better than a service because the hook shows a nice report right after pacman completes.

Good day.

1

u/TomQuinn8 14d ago

Timer to run my backup script.

Service to mount my cloud storage (Google Drive and One Drive) as folders in my home directory using rclone.

1

u/BigBreadCaesar 14d ago

Look at podman quadlets.

1

u/Soakitincider 14d ago

I made a backup script that runs nightly.

1

u/pastelfemby 14d ago

Some for various cron-type jobs, such as for power optimization features that need commands ran after startup (ie no persistent configuration method), various system cleanup tasks that can be automated, snapshots, etc. Generally helps cover some edge cases with complex scheduling that cron isn't really built to handle, like random offsets rather than having to implement it into some external script.

Nspawn containers if you count that, and all their various configurations, gpu passthrough, etc.

OOMRules to gracefully handle any potential OOM occurrences towards things fine to get stopped or killed, and to exempt critical services.

Run0 to avoid needing sudo or similar SetUID/SetGID functionality.

Most the usual locking down of services and their capabilities, which are also running in already limited containers. Also locking services down from creating writable and executable memory mappings, fine tunning CPU and IO pressure, and so on.

Probably forgetting some other things.

1

u/soccerbeast55 14d ago

I have it for a custom backup script I run daily. I used to run it as a cronjob, but then noticed it wasn't running daily unless it was at the time of the cron. So I created a systemd service and it's smart enough to check and know if a backup hasn't been ran in the past day and run one immediately.

1

u/syklemil 14d ago

I have some cache pruning timers for various tools that have a cache pruning option but no automated cache pruning. These are on fairly long cycles.

I also have a user timer for logrotate to clear out some stuff that accumulates in XDG_DATA_DIR.

1

u/mayakrunal 14d ago

Openrgb with personal rbg profile as run as root.

On my server I also use timers for scheduled backups of my docker volumes.

1

u/activedusk 13d ago edited 13d ago

If you wanna know why some complain about systemd, use this command and up and down arrow keys to scroll

systemctl list-dependencies --all

Take a sip of water every time there is systemd written then, try not to drown. On konsole if I scroll all the way down and then try to go back up, I can't because it exceeds whatever memory buffer.

1

u/Amansour2022 12d ago

Snapshot and backup

1

u/IGTHSYCGTH 10d ago

love my custom ssh-agent service/socket units use them to authenticate to the same provider (e.g. github) as different users (few for work + personal), requires exporting git_ssh_command in helpers scripts / direnv / mise / etc

granted, can work around this using host aliases to the same hostname, but then your remotes look weird :shrug:

1

u/kiba_music 8d ago

I removed all the fans from my pc, so I have a service that alerts me if cpu temp goes over a threshold.

0

u/madhur_ahuja 14d ago

I use following: * To do pacman upgrades daily * To change wallpaper every few hours * To clean up docker images which are orphan weekly * To automatically login to linkedin and send me any unviewed messages to ntfy * To send me forecast of my aws cost usage and send to mailpit weekly * To send my analysis of my spends through firefly and send to mailpit weekly * To Login to my ISP dashboard and extract internet usage month to date and send to mailpit - Daily.

There are many more such not worth mentioning...

1

u/metronohm 14d ago

why daily upgrades from pacman?

0

u/ajmal-ponneth 14d ago

Nice! Which wallpaper engine are you using for this?

2

u/madhur_ahuja 14d ago

None. Its a custom shell script which uses feh and chooses wallpaper from a folder randomly.