1 自动执行脚本
在Linux自动开机执行脚本的众多方法中,有一种是基于标准化的配置执行方式,该方式就是将执行脚本设置为自定义服务
,通过脚本的运行退出机制和启动顺序的设定来进行自启动脚本的标准化管理。
2 脚本的设定
2.1 创建脚本
在/etc/init.d/
下以管理员权限新建文件,在本例中为Button.sh
2.2 根据自身情况修改脚本
标准的脚本模板如下:
#!/bin/bash
### BEGIN INIT INFO
#
# Provides: Button
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: initscript
# Description: This file should be used to construct scripts to be placed in /etc/init.d.
#
### END INIT INFO
## Fill in name of program here.
PROG="Button "
PROG_PATH="/home/Button" ## Not need, but sometimes helpful (if $PROG resides in /opt for example).
PROG_ARGS=""
PID_PATH="/var/run/"
start() {
if [ -e "$PID_PATH