linux 起動時にコマンドを実行する

linuxで、起動時にコマンドを実行する手順を記述してます。
環境
- OS CentOS Linux release 7.9.2009 (Core)
手順
以下のファイルに実行したいコマンドを記述します。
vi /etc/rc.local
<出力結果>
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
ここに追加
ファイルに記述されている通り、以下に権限を付与します。
chmod +x /etc/rc.d/rc.local
これで、再起動すれば、起動時にコマンドが実行されていることが確認できます。
-
前の記事
php nullを判定する「null ===」と「is_null」のパフォーマンスを計測する 2021.11.14
-
次の記事
MySQL 最後にある半角スペースを除去する 2021.11.15
コメントを書く