0

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.

AndreKR
  • 1,100
  • Maybe you have size limits for the journalctl. Check the file: /etc/systemd/journald.conf and search for the value SystemMaxUse. – Edgar Magallon Dec 04 '22 at 20:43
  • @EdgarMagallon There's a single section [Journal] in it and all settings including SystemMaxUse are commented out. – AndreKR Dec 04 '22 at 20:45
  • Don't you have a Timer (systemd unit) or a cron job which cleans the journal logs? Something like journalctl --vacuum-size=100M is used to clear journal logs. – Edgar Magallon Dec 04 '22 at 20:53
  • @EdgarMagallon It's a pretty much stock Raspberry Pi OS, I didn't configure anything. Nothing in /etc/crontab nor in /var/spool/cron. – AndreKR Dec 04 '22 at 21:02
  • I think Raspberry based Linux OS are configured by default to delete logs after certain time. Or maybe systemd are deleting the logs as this answer said or this anwer as well. – Edgar Magallon Dec 04 '22 at 21:13
  • Maybe you should set SystemMaxUse to a large value (and then restart with systemctl 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

0 Answers0