Alpine linux如何配置和管理自定义服务


备忘

安装 rc-service 服务

Alpine使用的是OpenRCinit系统,而rc-service是openrc的一部分,所以安装openrc即可,使用如下命令安装:
apk add openrc --no-cache

添加自定义服务

vim /etc/init.d/xxx

#!/sbin/openrc-run
 
name="actc"
command="/path/to/${name}"
#command_background="yes"
 
depend() {
	after sshd
}

管理服务

  • 列出所有可用服务
    rc-service --list

  • 启动/停止/重启 已有服务
    rc-service 服务名 start/stop/restart
    OR
    /etc/init.d/服务名 start/stop/restart

设置开机自启动

rc-update add {service-name}

参考:

https://wiki.alpinelinux.org/wiki/Writing_Init_Scripts
https://dev.alpinelinux.org/~clandmeter/other/forum.alpinelinux.org/forum/installation/adding-custom-service-rc-service.html
https://www.cyberciti.biz/faq/how-to-enable-and-start-services-on-alpine-linux/
https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM