Answers for "write an ubuntu script that will start mysql service whenever it goes down"

0

write an ubuntu script that will start mysql service whenever it goes down

#!/bin/bash
if [[ ! "$(/usr/sbin/service mysql status)" =~ "start/running" ]]
then
    /usr/sbin/service mysql start
fi
Posted by: Guest on May-06-2022
0

write an ubuntu script that will start mysql service whenever it goes down

#!/bin/bash

# Check if MySQL is running
sudo service mysql status > /dev/null 2>&1

# Restart the MySQL service if it's not running.
if [ $? != 0 ]; then
    echo -e "MySQL Service was down. Restarting now...\n"
    sudo service mysql restart
else
    echo -e "MySQL Service is running already. Nothing to do here.\n"
fi
Posted by: Guest on May-06-2022

Code answers related to "write an ubuntu script that will start mysql service whenever it goes down"

Browse Popular Code Answers by Language