CentOS设置开机启动

2025年4月9日 7点热度 0人点赞 0条评论

AIO出现了硬盘问题,重启后发现离线下载服务没有开机自启,快速给开一下:

先写一个开机自启的脚本:

#!/bin/sh
#chkconfig: 2345 80 90
#description:aria2开机自启

aria2c --conf-path=/etc/aria2/aria2.conf -D

脚本第一行 “#!/bin/sh” 告诉系统使用的shell;
脚本第二行 “#chkconfig: 2345 80 90” 表示在2/3/4/5运行级别启动,启动序号(S80),关闭序号(K90);
脚本第三行 表示的是服务的描述信息
注意: 第二行和第三行必写,否则会出现如“服务 autostart.sh 不支持 chkconfig”这样的错误。

然后mv文件到/etc/rc.d/init.d/,并chmod +x赋予权限

最后添加到开机启动项:

chkconfig --add autostart.sh
chkconfig autostart.sh on

MuWinds

这个人很懒,什么都没留下

文章评论