openwrt开发板-开机启动配置
按启动时间
1. 修改启动文件
root@OpenWrt:~# vi /etc/rc.local
# Put your custom commands here that should be executed once # the system init finished. By default this file does nothing. echo "myscript is 1" >> /tmp/myscript.log cd /mnt/zb/config || { echo "cd failed" >> /tmp/myscript.log; exit 1; } ./tboxconfig >> /tmp/myscript.log 2>&1 echo "myscript is 2" >> /tmp/myscript.log exit 0
root@OpenWrt:~# chmod +x /etc/rc.local
2. 添加启动文件
脚本放入/etc/init.d:
touch /etc/init.d/myscript # 增加一个脚本
chmod 777 /etc/init.d/myscript # 将脚本设置为可执行文件
/etc/init.d/myscript start # 启动脚本
/etc/init.d/myscript stop # 停止脚本
/etc/init.d/myscript restart # 重启脚本
/etc/init.d/myscript reload # 重新加载配置文件,如果失败,重启服务
/etc/init.d/myscript enable # 开启开机自启动
/etc/init.d/myscript disable # 关闭开机自启动
/etc/init.d/myscript enabled # 检查是否在开机时启用
/etc/init.d/myscript status # 查看脚本的状态
root@OpenWrt:~# vi /etc/init.d/myscript
#!/bin/sh /etc/rc.common
START=99
start() {
cd /mnt && sh -c './tboxconfig > /dev/null 2>&1 &' ;
}
stop() {
echo "myscript is stop" >> /tmp/myscript.log
}
restart() {
echo "myscript is restart" >> /tmp/myscript.log
}
chmod 777 /etc/init.d/myscript
/etc/init.d/myscript start
/etc/init.d/myscript enable
查看空间剩余
df-h
存放在mnt下,可以避免系统挂载问题
环境变量()
vi /etc/profile
export PATH="/mnt/tboxconfig:$PATH"
source /etc/profile
echo $PATH