# 毎分 auto_start.sh の スクリプトを起動 (xxxは適当) * * * * * /bin/sh /xxx/auto_start.sh
#!/bin/sh n=`ps -ef | grep mysqld | grep -v grep | wc -l` if [ $n = 0 ]; then sudo service mysqld start fi n=`ps -ef | grep httpd | grep -v grep | wc -l` if [ $n = 0 ]; then sudo service httpd start fi
service mysqld status Redirecting to /bin/systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since 木 2021-07-01 15:25:05 JST; 36min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 19092 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 19058 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 19095 (mysqld) CGroup: /system.slice/mysqld.service mq19095 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid 7月 01 15:25:01 nuc20 systemd[1]: Starting MySQL Server... 7月 01 15:25:05 nuc20 systemd[1]: Started MySQL Server.
Redirecting to /bin/systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: inactive (dead) since 木 2021-07-01 16:01:51 JST; 1s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 19092 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 19058 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 19095 (code=exited, status=0/SUCCESS) 7月 01 15:25:01 nuc20 systemd[1]: Starting MySQL Server... 7月 01 15:25:05 nuc20 systemd[1]: Started MySQL Server. 7月 01 16:01:49 nuc20 systemd[1]: Stopping MySQL Server... 7月 01 16:01:51 nuc20 systemd[1]: Stopped MySQL Server.