相关疑难解决方法(0)

用一个 systemd 服务文件启动 N 个进程

我找到了这个 systemd 服务文件来启动 autossh 以保持 ssh 隧道:https : //gist.github.com/thomasfr/9707568

[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target

[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
# LOCALPORT:IP_ON_EXAMPLE_COM:PORT_ON_EXAMPLE_COM
ExecStart=/usr/bin/autossh -M 0 -N -q -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -p 22 -l autossh remote.example.com -L 7474:127.0.0.1:7474 -i /home/autossh/.ssh/id_rsa

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

有没有办法将 systemd 配置为在一个服务中启动多个隧道。

我不想创建N个系统服务文件,因为我想避免复制+粘贴。

除了“remote.example.com”将替换为其他主机名之外,所有服务文件都将相同。

1.5年后...

我大约在 1.5 年前问过这个问题。

我的想法变了。是的,这很好,你可以用 systemd …

daemon systemd

44
推荐指数
2
解决办法
7万
查看次数

chkconfig 支持 Linux 服务需要什么?

我正在尝试通过

chkconfig -add <servicename> 
Run Code Online (Sandbox Code Playgroud)

我收到一条消息说

service <servicename> does not support chkconfig
Run Code Online (Sandbox Code Playgroud)

我正在使用 Red Hat Enterprise 4。我试图在启动时添加到自动启动的脚本如下:

#!/bin/sh

soffice_start() {   if [ -x /opt/openoffice.org2.4/program/soffice ]; then
        echo "Starting Open Office as a Service"
        #echo " soffice -headless -accept=socket,port=8100;urp;StarOffice.ServiceManager
-nofirststartwizard"
        /opt/openoffice.org2.4/program/soffice
-headless -accept="socket,host=0.0.0.0,port=8100;urp;StarOffice.ServiceManager"
-nofirststartwizard &   else
        echo "Error: Could not find the soffice program. Cannot Start SOffice."   fi }

soffice_stop() {   if [ -x /usr/bin/killall ]; then
        echo "Stopping Openoffice"
        /usr/bin/killall soffice 2> /dev/null   else
        echo "Eroor: Could not find killall.  Cannot …
Run Code Online (Sandbox Code Playgroud)

scripting linux redhat chkconfig

37
推荐指数
2
解决办法
7万
查看次数

标签 统计

chkconfig ×1

daemon ×1

linux ×1

redhat ×1

scripting ×1

systemd ×1