为什么一个“bash”命令在启动时不起作用

Opt*_*ime 1 startup bash lubuntu upstart bashrc

我正在使用 Lubuntu 14.04 开发 VM,

我已经创建了一个脚本 a.sh,

#!bin/bash
echo "aaaa" >> a.txt
Run Code Online (Sandbox Code Playgroud)

我的 /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.

bash /home/sentinel/a.sh
echo "hey" >> /home/sentinel/b.txt
exit 0
Run Code Online (Sandbox Code Playgroud)

在重新启动我的机器时,我可以看到 b.txt 是用内容构建的,hey但是 a.txt 没有被构建。有人可以在这里帮助我吗?

rɑː*_*dʒɑ 8

提及 a.txt 应创建的完整路径。

你的脚本应该是:

#!/bin/bash
echo "aaaa" >> /home/sentinel/a.txt
Run Code Online (Sandbox Code Playgroud)

我在这里发帖之前已经尝试过这个。

添加的行rc.local作为

./home/sentinel/a.sh
Run Code Online (Sandbox Code Playgroud)

保存并重新启动您的电脑。

  • 你还打吗,兄弟? (3认同)