我有一个很长的命令行要放入 systemd ExecStart 条目中。我知道我可以通过用反斜杠结束每个非最终行来将长行分成多行。
但是,如何记录带有注释的部分?例如,以下内容将不起作用:
ExecStart=/bin/ssh -NT -o ExitOnForwardFailure=yes -o ServerAliveInterval=60 -o ServerAliveCountMax=3 \
# local tunnel for this
-L 172.16.12.34:10001:localhost:10001 \
# remote tunnel for that
-R3128:127.0.0.1:3128 \
someserver
Run Code Online (Sandbox Code Playgroud)
如果我删除带有“#”的行,它会起作用,但随后我会丢失文档。如果对长命令行的各个部分进行细粒度就地文档基本上是不可能的,那么有哪些有用的替代方案?
art*_*bot 11
I think this is what @sven suggests:
#
# Listen locally on port 10001 and tunnel it to someserver
# Listen on someserver port 3128 and tunnel it to localhost
#
ExecStart=/bin/ssh -NT \
-o ExitOnForwardFailure=yes \
-o ServerAliveInterval=60 \
-o ServerAliveCountMax=3 \
-L 172.16.12.34:10001:localhost:10001 \
-R3128:127.0.0.1:3128 \
someserver
Run Code Online (Sandbox Code Playgroud)
Doesn't look too bad to me.
小智 7
只是不要忘记\
在行尾加上注释。Systemd 将剪切它们并且不在命令中使用
ExecStart=/bin/ssh -NT \
-o ExitOnForwardFailure=yes \
-o ServerAliveInterval=60 \
-o ServerAliveCountMax=3 \
# local tunnel for this \
-L 172.16.12.34:10001:localhost:10001 \
# remote tunnel for that \
-R3128:127.0.0.1:3128 \
someserver
Run Code Online (Sandbox Code Playgroud)
Sve*_*ven -1
归档时间: |
|
查看次数: |
14348 次 |
最近记录: |