所以我有一个 bash 脚本来/etc/init.d/
包含这个初始化信息:
### BEGIN INIT INFO
# Provides: minio server
# Required-Start: $local_fs $remote_fs $mysql $all
# Required-Stop: $remote_fs $syslog
# Default-Start: 5
# Default-Stop:
# Short-Description: Start minio server that were running during shutdown
# Description: Start minio server that were running during shutdown, wether unexpected or not
### END INIT INFO
因为这个脚本需要 mariadb 才能运行,所以我将其放入$mysql
必需的启动中,即使$all
(根据我的理解)应该已经确保 mariadb 已启动,因为文件头mysql
如下所示:
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network $named $time
# Should-Stop: $network $named $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the mysql database server daemon
# Description: Controls the main MariaDB database server daemon "mysqld"
# and its wrapper script "mysqld_safe".
### END INIT INFO
所以脚本正在检查这个守护进程是否正在运行:
for seconds in {1..60}
do
sleep 1
find_pid=$(ps 'aux'| grep "sql")
pid="${find_pid:5:25}"
stringarray=($pid)
pid=${stringarray[0]}
find_pid=$(ps 'aux'| grep "sql")
pid_two="${find_pid:5:25}"
stringarray=($pid_two)
pid_two=${stringarray[0]}
if [ $pid == $pid_two]; then
break
fi
done
if [[ $seconds == 60 ]]; then
echo "database not started yet" | tee -a /var/www/html/startup.log
fi
但由于某种原因,执行脚本时数据库从未启动。有人知道如何解决这个问题吗?
编辑:我也尝试过这但即使update-rc.d YOURAPP defaults
按照链接中的建议运行后,运行脚本时数据库也不会启动。
答案1
不要将其保存在 中,而是init.d
尝试将脚本添加到/etc/rc.local
EG:打开/etc/rc.local,然后
path_to_binary path_to_scipt