Score:0

How to execute some command always after hard reboot (ubuntu server)?

us flag

I am facing an issue that everytime I hard restart my server (maybe went bananas due to out of memory, ddosed etc) supervisor fails to run. And the reason for that is identified and simply /var/run/supervisor directory is deleted.

I learned that /var/run folders are deleted on hard reboot (via ec2 panel for instance force stop then start), so my humble question is:

How can I execute this mkdir /var/run/supervisor after every hard reboot ? Where is the perfect place to add such logic. I guess it is not /etc/profile for sure

(the rest works fine, supervisor is configured as service + uses unix sock at var/run/supervisor/supervisor.sock)

My ubuntu version:

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

Score:1
in flag

In Ubuntu 20 I would expect that supervisor is started as a systemd service unit.

In the service unit for supervisor you need to specify that the directory is created: (the unit name might be different)

https://serverfault.com/a/779648 & https://serverfault.com/a/840999

sudo systemctl edit --full supervisor

and add a directive:

RuntimeDirectory=supervisor 
us flag
Thank you. I edited `systemctl edit --full supervisord.service` because nothing was found with supervisor to ```[Unit] Description=Supervisor daemon Documentation=http://supervisord.org After=network.target [Service] ExecStart=/usr/local/bin/supervisord -n -c /etc/supervisord.conf ExecStop=/usr/local/bin/supervisorctl $OPTIONS shutdown ExecReload=/usr/local/bin/supervisorctl $OPTIONS reload KillMode=process Restart=on-failure RestartSec=42s RuntimeDirectory=supervisor [Install] WantedBy=multi-user.target Alias=supervisord.service ```
us flag
I chose your answer as solution , thank you. Next time hard reboot happens can verify if worked correctly
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.