If my server manages to crash due to an out of memory error or failed status check, how should I go about the recovery of the system so my systemd services will restart.

0

If my server manages to crash due to an out of memory error or failed status check, how should I go about the recovery of the system so my systemd services will restart.

IC
asked 5 months ago134 views
1 Answer
0

Systemd can automatically restart crashed services if configured properly. Check your unit files for Restart and RestartSec options.

ere's an example of automatic recovery using systemd, focusing on your scenario of memory issues:

Unit file configuration:

[Unit]
Description=My Important Service

[Service]
Restart=unless-stopped
RestartSec=30
LimitMEMLock=50%
ExecStart=/path/to/my/service

[Install]
WantedBy=multi-user.target

to identify the issue:

Check your system logs (e.g., dmesg, journalctl) for clues about the crash. Is it memory overflow, a specific service failure, or something else? If memory is the culprit, analyze historical memory usage and identify peak times or processes consuming too much.

profile picture
EXPERT
answered 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions