我有一个脚本,我想在我的系统启动时运行它并将其放入 中/etc/rc.local,但它不起作用。我怎样才能让它在启动时运行?
我有以下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.
sh /home/incero/startup_script.sh
/bin/chmod +x /script.sh
sh /script.sh
exit 0
Run Code Online (Sandbox Code Playgroud)
第一行,startup_script.sh实际下载第三行中提到的script.sh文件/script.sh。
不幸的是,它似乎没有使脚本可执行或运行脚本。 …
在之前安装的 kubuntu 15.xx 版本中,我添加了一行/etc/rc.local-/home/diet/scripts/my-auto-mount-script这显然是指一个脚本,如果在家庭 wifi 网络驱动器上应该安装。
这在 kubuntu 15.xx 上完美无缺
升级后,它似乎/etc/rc.local在启动时被忽略,因为运行该命令/etc/rc.local似乎仍然可以解决问题。我认为 rc.local 被忽略的原因是因为它引用的脚本应该在脚本成功和脚本失败时生成日志,但没有日志。
谁能给我一些有关如何解决此问题的指示?
PS:是的,我知道放入东西/etc/fstab也是安装驱动器的一种方式,但是当我不在家时,我讨厌我可以看到海豚上的驱动器并且上面有那些小红叉,因为它们不在那里. 这样当我在路上(它是一台笔记本电脑)时,人们看不到我家里的东西。
我创建了一个脚本来启用我的蓝牙驱动程序。然后我使用 rc.local 从启动时运行它。但是,这是行不通的。
运行命令时,systemctl status rc-local.service我得到:
Failed to issue method call: no such interface 'org.freedesktop.DBus.Properties'
on object at path /org/freedesktop/systemd1/unit/rc_2dlocal_2eservice
Run Code Online (Sandbox Code Playgroud)
我应该得到的东西,看起来像这样:
rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
??debian.conf
Active: active (running) since Mon 2018-04-02 10:39:44 -03; 1s ago
Process: 2044 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
Main PID: 2049 (svscanboot)
Tasks: 3
Memory: 556.0K
CPU: 10ms
CGroup: /system.slice/rc-local.service
Run Code Online (Sandbox Code Playgroud)
我的所有文件都是可执行的 (
chmod 755 [filename]),并且我验证了 rc.local 应该使用sudo /etc/init.d/rc.local start和运行sudo …