相关疑难解决方法(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万
查看次数

在没有 for 循环的情况下重新启动 systemctl 上的所有特定单元?

这里有人能够启动/停止/重新加载/...使用通配符或 systemctl 上的类似方法指定的单位列表吗?

我尝试做类似的事情:systemctl restart openstack-nova-*.servicessystemctl restart openstack-nova-?.services

但这是一个死胡同,我在 systemctl 的手册上没有找到任何有用的东西。

我可以使用 for 循环,但在此之前我必须systemctl -t service --failed为列出的单位制作一个然后 grep ......有点无聊不是吗?

所以,如果有人知道是否可以做这样的事情,我会很高兴听到的。

如果不是,我想我会在 systemctl 开发人员列表上提出这个想法,或者如果我有时间的话可能会打补丁 ^^

recursive systemctl

6
推荐指数
1
解决办法
2060
查看次数

标签 统计

daemon ×1

recursive ×1

systemctl ×1

systemd ×1