Mohammad Emran Hasan
Mohammad Emran Hasan

Follow

Mohammad Emran Hasan

Follow

Auto-restart MariaDB when it dies

Mohammad Emran Hasan's photo
Mohammad Emran Hasan
·Mar 24, 2018·

1 min read

I am running a small, low-memory VPS where MariaDB is frequently killed by the system due to lack of memory. Since I wanted to keep the budget fixed and didn’t have enough time to look under the hood to find the root cause, I opted in for running a cron to periodically check and start MariaDB if its not running.

* * * * * /bin/systemctl status mariadb.service > /dev/null || /bin/systemctl start mariadb.service

The double pipe || means OR and will execute the 2nd command if the first command fails somehow. (Returns an exit code greater than zero.)

 
Share this