/etc/rc.local在启动时没有运行命令

/etc/rc.local在启动时没有运行命令

问题描述:

我一直试图解决这个问题一个星期了,无法让它工作。我添加到/etc/rc.local的任何命令在启动时都不会执行。 我已经tryed如下:/etc/rc.local在启动时没有运行命令

# chmod +x /etc/rc.local 

# chmod 775 /etc/rc.local 

# ls -l /etc/rc.local 
-rwxr-xr-x 1 root root 584 Jul 13 17:09 /etc/rc.local 

# ls -l /etc/init.d/rc.local 
-rwxr-xr-x 1 root root 820 Apr 6 2015 /etc/init.d/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. 
printf "Hello World" 
exit 0 

,如果我从终端运行该文件它打印的问候世界,但在启动时什么都没有,所以问题就不是文件。

任何想法?

顺便说一句。我用rapbian操作系统运行它

+0

Stack Overflow是编程和开发问题的网站。这个问题似乎与题目无关,因为它不涉及编程或开发。请参阅帮助中心的[我可以询问哪些主题](http://stackoverflow.com/help/on-topic)。也许[Raspberry Pi Stack Exchange](https://raspberrypi.stackexchange.com/),[物联网堆栈交换](https://iot.stackexchange.com/)或[Unix&Linux Stack Exchange](http: //unix.stackexchange.com/)会是一个更好的地方。 – jww

+1

这样的消息很难找到。使用'printf'Hello World>>/tmp/myfile'来代替'/ tmp/myfile'来代替 –

printf "Hello World" 
exit 0 

它也不起作用utuntu了。我不知道确切的原因,它似乎是/etc/rc.local的独特特征。它的输出可能没有通过标准输出(显示器1)连接,但其他命令有效。我看到了。

如果你想知道更多关于/etc/rc.local的细节,这个link可能会有所帮助。

+1

嗨,Elvis Jang,欢迎来到SO,在这里你可以找到关于格式化你的答案的信息:https ://meta.stackexchange.com/help/formatting。 –