Linux系统设置开机启动(草稿)
Debian系统
验证未通过,发现每次都是写两次
且移除自启动并未成功
-
在/etc/init.d下新建test,内容如下
#!/bin/sh ### BEGIN INIT INFO # Provides: test # Required-Start: $network $remote_fs $local_fs # Required-Stop: $network $remote_fs $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: test # Description: test的说明 ### END INIT INFO #需要执行的命令,示例 echo "Hello world!" `date +"%Y-%m-%d %H:%M:%S"` >> /root/test.txt exit 0 -
设置为可运行
chmod +x test -
添加到开机启动
update-rc.d test defaults #移除命令 #update-rc.d -f test remove -
查看系统开机自动启动项目:
service --status-all -
标准文件格式说明
#!/bin/sh ### BEGIN INIT INFO # Provides: [程序名称,唯一] # Required-Start: $network $remote_fs $local_fs # Required-Stop: $network $remote_fs $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: [启动项的简短说明] # Description: [启动项的完整说明] ### END INIT INFO [需要执行的命令] exit 0

浙公网安备 33010602011771号