I have written a program that logs to stderr. I run it as a service with systemd. Here's the unit file:
[Unit]
Description=Mi Scale Translator
After=network.target
[Service]
Type=simple
Restart=always
ExecStart=/root/miscale/miscale
[Install]
WantedBy=multi-user.target
Every couple of days the service stops working. When I check the status this is the output:
# systemctl status miscale
● miscale.service - Mi Scale Translator
Loaded: loaded (/root/miscale.service; linked; vendor preset: enabled)
Active: inactive (dead)
I thought Restart=always would prevent exactly this, but apart from that there are also no logs:
# journalctl -u miscale
-- Logs begin at Thu 2019-02-14 10:11:58 GMT, end at Sun 2022-12-04 20:18:38 GMT. --
-- No entries --
I now restarted it with systemctl start miscale and there are logs:
# journalctl -u miscale
-- Logs begin at Thu 2019-02-14 10:11:58 GMT, end at Sun 2022-12-04 20:20:31 GMT. --
Dec 04 20:19:17 raspberrypi systemd[1]: Started Mi Scale Translator.
But I'm sure when I check again in a few days, the service will be dead again and the logs will have disappeared.
/etc/systemd/journald.confand search for the valueSystemMaxUse. – Edgar Magallon Dec 04 '22 at 20:43[Journal]in it and all settings includingSystemMaxUseare commented out. – AndreKR Dec 04 '22 at 20:45Timer(systemd unit) or acronjob which cleans the journal logs? Something likejournalctl --vacuum-size=100Mis used to clear journal logs. – Edgar Magallon Dec 04 '22 at 20:53/etc/crontabnor in/var/spool/cron. – AndreKR Dec 04 '22 at 21:02Raspberrybased Linux OS are configured by default to delete logs after certain time. Or maybesystemdare deleting the logs as this answer said or this anwer as well. – Edgar Magallon Dec 04 '22 at 21:13SystemMaxUseto a large value (and then restart withsystemctl restart systemd-journald). You can create a service that generate a lot of logs to test when the journal is being cleared. – Edgar Magallon Dec 04 '22 at 21:17