Systemd service that restarts too eagerly

Back to list2024-02-16
You

My service restarts in a loop and floods the journal.

ChatGPT

Add a backoff. RestartSec=5 plus StartLimitIntervalSec=120 and StartLimitBurst=5 turns a hot loop into five attempts and then a stop, which is what you want: a service that cannot start should stay down loudly rather than churn quietly.

You

journalctl output is overwhelming during an incident.

ChatGPT

Narrow before you read: journalctl -u myservice --since "10 min ago" -p warning gives the unit, the window and the severity in one line. -o cat strips the metadata once you know where you are.

You

Two users need to write to the same folder without stepping on each other.

ChatGPT

A shared group plus the setgid bit: chgrp team dir && chmod 2775 dir. New files inherit the group, which is the part plain chmod 775 misses and the reason it stops working on the second day.

You

Does this still hold if I am working alone?

ChatGPT

It gets easier, not harder. A fair share of the difficulty is coordination, and that disappears. What remains is remembering your own decisions, which is what writing them down is for.