Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
208 views
in Technique[技术] by (71.8m points)

linux - How create/use services with OpenRC?

I'm used to create and use services with systemd like that :

XXXX.service :

[Unit]
Description=Report Service

[Service]
Type=Simple
ExecStart=/path/to/my/script.sh

XXXX.timer :

[Unit]
Description=Timer for Report Service

[Timer]
OnCalendar=*-*-* 2:00:00
Persistent=true

[Install]
WantedBy=timers.target

But now, I've to use OpenRC and I don't really understand how it works !

There is someone to explain how OpenRC work and based on my example, how to create a service with OpenRC, in order to learn how to use it ?

Thanks a lot !

question from:https://stackoverflow.com/questions/65942607/how-create-use-services-with-openrc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Probably the best option to learn is this.

The base script is like this:

#!/sbin/openrc-run
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

name="service"
description=""
command="/path/to/dir/"
command_args="${service_args}"
#command_user="user:user"

depend() {

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...