Answer the question
In order to leave comments, you need to log in
How to resume the process when it crashes?
Sometimes a process crashes in ubuntu server 16.04 that should be running all the time.
in order not to monitor its work 24/7, tell me, can you somehow make it so that ubuntu automatically starts this process when it crashes?
in more detail: the process /usr/bin/java -server -Xmx5200M -Xms2048M -jar minecraft_server.1.12.2.jar nogui may crash. when it crashes, I would like the same command to be automatically reproduced and the server was raised,
but not from the root user, but on behalf of another user.
Can you tell me if this can be done?
Answer the question
In order to leave comments, you need to log in
It is possible with the help of systemd (IMHO, the most correct). You can write an external watchdog, you can check once a minute for a cron whether there is a process, and if it is not there, then start.
Google "systemd minecraft", there are ready-made configs there, for your Wishlist.
Use systemd ! You write a simple service file in which you define both the user and the directory, you can still drive all this into cgroups, and make a separate directory.
Create file /lib/systemd/system/minecraft.service
[Unit]
Description=Gunicorn Site
#Requires=gunicorn.socket
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=/opt/gunicorn
ExecStart=/opt/venv/bin/gunicorn -w 4 --bind localhost:8000 wsgi:app
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=no
[Install]
WantedBy=multi-user.target
systemctl start minecraft
systemctl enable minecraft
systemctl status minecraft
systemctl stop minecraft
systemctl disable minecraft
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question