0

Is it possible to monitor systemd service (unit), if it produces logs, and if no log is produced in (lets say 5 minutes), restart the service?

1

So you can put logic based on below scenarios:

[1] Check pid if exists, if not restart application.

[2] Check log if not produced for some time(check what threshold you want to put), restart service.

journalctl <your application binary>

[3] If your application support endpoints for health check, you can write on top of it.

Actually we need to identify difference between idle and not working while checking logs, So I think checking single thing is not enough.

  • Thank you, [1] is not feasible, as the app seems to be running, however it is hanged, if it doesn't produce any logs, [2] is what I'm talking about, but I'm looking for automated solution, not manually checking, manually restarting scenario, [3] it does not support, it's 3rd party closed-source, which lacks this. [2] is great indication of "not working", because it actively sends out heartbeat and logs that action in syslog, so there is no idle-state confusion. – Marek Sebera May 28 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.