[20201112]centos 7 rc.local shell script on systemd while booting Linux system.t

lfree發表於2020-11-12

[20201112]centos 7 rc.local shell script on systemd while booting Linux system.txt

--//centos 7開始全面使用systemd管理啟動過程,說真的我自己非常不習慣,也許是老了,接受新生事物有點遲鈍。
--//而以前使用者要加入一些特殊命令一般都是選擇/etc/rc.d/rc.local.但是centos 7開始不會再呼叫執行。

# ls -l /etc/rc.local /etc/rc.d/rc.local
-rw-r--r--. 1 root root 485 2020-11-12 10:28:16 /etc/rc.d/rc.local
lrwxrwxrwx. 1 root root  13 2020-02-27 01:51:51 /etc/rc.local -> rc.d/rc.local

# systemctl status rc-local.service
* rc-local.service - /etc/rc.d/rc.local Compatibility
   Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled)
   Active: inactive (dead)

# systemctl enable rc-local.service

# systemctl start rc-local.service

# systemctl status rc-local.service
* rc-local.service - /etc/rc.d/rc.local Compatibility
   Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled)
   Active: inactive (dead)
Condition: start condition failed at Thu 2020-11-12 10:34:12 CST; 3s ago
           ConditionFileIsExecutable=/etc/rc.d/rc.local was not met
--//不行。

# ls -l /etc/rc.d/rc.local
-rw-r--r--. 1 root root 485 2020-11-12 10:28:16 /etc/rc.d/rc.local
--//沒有執行許可權。

# chmod 744 /etc/rc.d/rc.local

# systemctl start rc-local.service

# systemctl status rc-local.service
* rc-local.service - /etc/rc.d/rc.local Compatibility
   Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled)
   Active: active (exited) since Thu 2020-11-12 10:36:05 CST; 1s ago
  Process: 8078 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)

Nov 12 10:36:05 localhost.localdomain systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
Nov 12 10:36:05 localhost.localdomain rc.local[8078]: test
Nov 12 10:36:05 localhost.localdomain systemd[1]: Started /etc/rc.d/rc.local Compatibility.

--//ok現在已經執行成功了。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2733684/,如需轉載,請註明出處,否則將追究法律責任。

相關文章