linux systemd: 启用/etc/rc.local
1.创建文件rc-local.service文件
sudo vi /etc/systemd/system/rc-local.service
文件内容
[Unit] Description=/etc/rc.local Compatibility ConditionPathExists=/etc/rc.local [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target
2.创建rc.local文件(如果不存在的话)
sudo vi /etc/rc.local
文件内容举例
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. exit 0
确保rc.local可执行
sudo chmod +x /etc/rc.local
3.启用rc-local.service
sudo systemctl enable rc-local sudo systemctl start rc-local.service
查看rc-local.service状态
sudo systemctl status rc-local.service
正常情况下得到类似的输出
hadoop@rick-ubuntu:/etc$ sudo systemctl status rc-local.service ? rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled) Drop-In: /lib/systemd/system/rc-local.service.d ??debian.conf Active: active (exited) since Tue 2017-06-20 18:11:15 CST; 3s ago Process: 27999 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS) 6? 20 18:11:15 rick-ubuntu systemd[1]: Starting /etc/rc.local Compatibility... 6? 20 18:11:15 rick-ubuntu systemd[1]: Started /etc/rc.local Compatibility.
相关推荐
Schvian 2020-11-04
hpujsj 2020-07-26
txj 2020-06-12
suosuo 2020-06-08
suosuo 2020-05-28
cwgxiaoguizi 2020-05-28
夜雨倚琴 2020-04-19
liusaisoso 2020-01-17
scmrpu 2020-01-17
csdnyasin 2020-01-10
csdnyasin 2020-01-05
糊一笑 2019-12-20
83530391 2019-12-12
sweetgirl0 2019-12-07
bearhoopIT之道 2019-11-24
Caleb0 2019-11-26