今天在pi3的/etc/rc.local配置了命令,发现启动没执行
在rc.local里我那天命令前加入echo“running rc.local”> /tmp/pre_test.txt
然后重启,tmp目录也没有输出。
使用chmod +x /etc/rc.local命令也没用
其实我X权限有的
真是让人头大。
最后检查服务状态sudo systemctl status rc-local发现了问题:
根据错误的提示,运行sudo systemctl daemon-reload,依旧没啥作用。
最后只能换种方法,在/etc/init.d/下建立init-app文件
#!/bin/sh #/etc/init.d/init-app ### BEGIN INIT INFO # Provides: get-ip-address # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: init-app # Description: This service is used to start init shell ### END INIT INFO case "$1" in start) echo "Starting init.sh" sh /var/app/init.sh ;; stop) echo "Stop" ;; *) echo "Usage: service init-app start|stop" exit 1 ;; esac exit 0
保存
添加权限
sudo chmod 777 /etc/init.d/init-app
加到开机启动
sudo update-rc.d init-app defaults