CentOS7のrc.local


最近、rhel7系を触り始めました。

firewalldはiptablesに変更するなど、rhel6系からの移行はゆるーくいこうかなと考えてます。

とりあえず、7系になって違うところを共有していこうと思います。

まずは、rc.local

普通にファイルがあったので、とりあえずコマンドを書き込んでみたのですが、

起動時に実行してくれないようです。

systemdで管理されているようなので、
/usr/lib/systemd/system/rc-local.service
を覗くと実行権限が付与されている場合に読みだされると書いてある。

# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.d/rc.local is executable.
[Unit]
Description=/etc/rc.d/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
SysVStartPriority=99

ということで、chmod u+x /etc/rc.d/rc.localとして起動してみたところ問題なく実行されてました。

ちなみに起動後に再度読み込ませたい場合は

systemctl start rc-local

で再実行が可能です。

カテゴリー: 小ネタ パーマリンク

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>