ubuntu14.04 编辑/etc/rc.local 可以执行开机脚本,
但是后面的版本不行了,
得用下面的办法修复:
https://zhuanlan.zhihu.com/p/364133732
修改:/etc/systemd/system/rc-local.service:
# SPDX-License-Identifier: LGPL-2.1+
#
# 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.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=5
RemainAfterExit=yes
GuessMainPID=no
[Install]
WantedBy=multi-user.target
Alias=rc-local.service
/etc/rc.local
#!/bin/bash
echo 00000000000000 > /tmp/x.log
vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs-fuse,allow_other,entry_timeout=3,negative_timeout=3,attr_timeout=3,auto_cache
echo 9999999999999 >> /tmp/x.log
sudo chmod +x /etc/rc.local
接下来是启动服务:
①.刷新systemctl配置
sudo systemctl daemon-reload
②.设置开机启动
sudo systemctl enable rc-local.service
③.启动服务
sudo systemctl start rc-local.service
④.测试服务的状态
sudo systemctl status rc-local.service
以后就能开机运行 /etc/rc.local的脚本了!
离线
/etc/rc.d的启动方式是SysVinit,只能串行执行系统启动脚本,启动速度慢,已经被遗弃了。
现在的启动方式都是Systemd了,不知为何现在很多人诟病Systemd,我记得Systemd引进之初是为了解决SysVinit只能串行启动导致启动速度慢,而仿效MacOS进行并行启动来提高启动速度的。
建议放弃SysVinit了,以后Systemd也可能不再兼容SysVinit
离线
很多人指责systemd是因为它做的事情太多了,违反了UNIX哲学。
离线