树莓派开机执行命令脚本

 

 

在目录/etc/init.d/创建a文件

#!/bin/sh
#/etc/init.d/a
### BEGIN INIT INFO
# Provides:testboot
# Required-Start:$remote_fs $syslog
# Required-Stop:$remote_fs $syslog
# Default-Start:2 3 4 5
# Default-Stop:0 1 6
# Short-Description: testboot
# Description: This service is used to start my applaction
### END INIT INFO
case "$1" in
  start)
    echo "启动"
    su root -c "vncserver"
  ;;
  stop)
    echo "关闭"
  ;;
  *)
    echo "不知道是啥"
    exit 1
  ;;
esac

保存

执行命令

设置权限
sudo chmod 777 /etc/init.d/a
更新加载启动
sudo update-rc.d a defaults

这样树莓派开机就会自动执行

su root -c "vncserver"

root身份执行vncserver启动vnc的意思

 

 

 

 

 

你可能感兴趣的:(树莓派,树莓派,开机启动,开机执行命令)