启动系统时未调用 rc.local

启动系统时未调用 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.

touch /home/jack/test.txt
bash /home/jack/Scripts/select_wallpaper.sh

exit 0

手动执行脚本时不会出现任何问题,一切正常。我尝试将测试命令touch放入 rc.local,但什么也没发生!?我检查过sysv-rc-conf,它已启用!我遗漏了什么??

以下是我的/etc/init.d/rc.local

 #! /bin/sh
### BEGIN INIT INFO
# Provides:          rc.local
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
    if [ -x /etc/rc.local ]; then
        [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
    /etc/rc.local
    ES=$?
    [ "$VERBOSE" != no ] && log_end_msg $ES
    return $ES
fi
}

echo $1 > /home/jack/test.txt

case "$1" in
start)
do_start
    ;;
restart|reload|force-reload)
    echo "Error: argument '$1' not supported" >&2
    exit 3
    ;;
stop)
    ;;
*)
    echo "Usage: $0 start|stop" >&2
    exit 3
    ;;
esac

我自己插入了这一行echo $1 > /home/dan/test.txt,但那里什么都没写!?当我执行它时,sudo /etc/init.d/rc.local start一切正常,只是在启动系统时不行!?

答案1

我把脚本放在启动应用程序中,现在它运行正常

相关内容