archdaily_Arch linux操作系统设置开机启动配置

更新时间:2019-11-05    来源:linux    手机版     字体:

【www.bbyears.com--linux】


顺便说一下Centos 7 中rc.local其实依然是可以使用的,无法使用的原因是由于/etc/rc.d/rc.local中没有X权限,增加一个执行权限即可。

既然centos中的可以使用,哪么arch linux中其实也是可以使用的。直接copycentos中的资料即可。

[root@Arch ~]# egrep -v "#" /usr/lib/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
[root@Arch ~]# touch /etc/rc.local
[root@Arch ~]# chmod +x /etc/rc.local
[root@Arch ~]# systemctl enable rc-local.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rc-local.service to /usr/lib/systemd/system/rc-local.service.
[root@Arch ~]# cat /etc/rc.local
ulimit -HSn 30961 && echo "right" >>/tmp/right.txt || echo "wrong" >>/tmp/wrong.txt
printf $(ulimit -n) >>/tmp/ulimit1.txt 2>&1
ulimit -HSn 3096
printf $(ulimit -n) >>/tmp/ulimit.txt 2>&1

测试:

[root@Arch ~]# ls -al /usr/lib/systemd/system/rc-local.service
-rw-r--r-- 1 root root 675 Apr  5 23:24 //usr/lib/systemd/system/rc-local.service
[root@Arch ~]# chmod +x /usr/lib/systemd/system/rc-local.service
[root@Arch ~]# ls -al /usr/lib/systemd/system/rc-local.service
-rwxr-xr-x 1 root root 675 Apr  5 23:24 //usr/lib/systemd/system/rc-local.service
[root@Arch ~]# systemctl start rc-local.service
Job for rc-local.service failed. See "systemctl status rc-local.service" and "journalctl -xe" for details.
[root@Arch ~]# systemctl status rc-local.service
● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sun 2015-04-05 23:30:27 UTC; 9s ago
  Process: 246 ExecStart=/etc/rc.local start (code=exited, status=203/EXEC)
Apr 05 23:30:27 Arch systemd[1]: rc-local.service: control process exited, code=exited status=203
Apr 05 23:30:27 Arch systemd[1]: Failed to start /etc/rc.local Compatibility.
Apr 05 23:30:27 Arch systemd[1]: Unit rc-local.service entered failed state.
Apr 05 23:30:27 Arch systemd[1]: rc-local.service failed.
[root@Arch ~]# ls -al /usr/lib/systemd/system/sshd.service     #排除权限原因
-rw-r--r-- 1 root root 410 Mar 20 04:52 /usr/lib/systemd/system/sshd.service
[root@Arch ~]# journalctl -xe
Apr 05 23:29:34 Arch systemd[1]: Configuration file /usr/lib/systemd/system/rc-local.service is marked executable. Please remove exec
Apr 05 23:29:38 Arch systemd[1]: rc-local.service: control process exited, code=exited status=203
-- Subject: Unit rc-local.service has failed
-- Unit rc-local.service has failed.
Apr 05 23:29:38 Arch systemd[1]: Unit rc-local.service entered failed state.
Apr 05 23:29:38 Arch systemd[1]: rc-local.service failed.
[root@Arch ~]# systemctl start rc-local.service
Warning: Unit file of rc-local.service changed on disk, "systemctl daemon-reload" recommended.
Job for rc-local.service failed. See "systemctl status rc-local.service" and "journalctl -xe" for details.
[root@Arch ~]# systemctl | grep rc-loca
rc-local.service                                                                    loaded active exited    /etc/rc.local Compatibility
[root@Arch ~]# cat /etc/rc.local
#!/bin/sh
[root@Arch ~]# egrep -v "#" /etc/systemd/system/multi-user.target.wants/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target

rc.loca在Arch中无法启动的原因是由于我在rc.loca中没有设置#!/bin/sh导致的!!!

本文来源:http://www.bbyears.com/caozuoxitong/77468.html

热门标签

更多>>

本类排行