起動スクリプトが必要なときに起動しません。

起動スクリプトが必要なときに起動しません。

/etc/init.d/したがって、次の初期化情報を含むbashスクリプトがあります。

 ### 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が必要なので(私が理解したように)、ファイルヘッダーは次のようになっているので、mariadbを起動する必要がありましたが、$mysql必須の起動に入れました。$allmysql

### 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

例:/etc/rc.localを開き、

path_to_binary path_to_scipt

おすすめ記事