$ sudo service mysql status
* /usr/bin/mysqladmin Ver 8.42 Distrib 5.7.29, for Linux on x86_64
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.7.29-0ubuntu0.18.04.1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 38 min 26 sec
Threads: 1 Questions: 40 Slow queries: 0 Opens: 107 Flush tables: 1 Open tables: 26 Queries per second avg: 0.017
$ sudo service mysql status
* MySQL is stopped.
В какой файл?В ~/.bashrc.
#!/bin/bash
# run custom services
services_list="php7.0-fpm php7.1-fpm php7.2-fpm php7.3-fpm php7.4-fpm mysql redis-server"
for svc in ${services_list}
do
service_status=$(sudo service $svc status)
if [[ $? != "0" ]]; then
#if [[ $service_status = *"is not running"* ]] || [[ $service_status = *"is stopped"* ]]; then
sudo service $svc start &
#sudo service $svc status
fi
done
exit 0