【发布时间】:2019-11-15 23:14:31
【问题描述】:
我在 2010 年运行 Mavericks 的 MBA 上运行 autossh。该脚本运行良好,并且在命令行中按预期工作,但在由 launchd 运行时却不行。
我尝试在启动的 plist 中包含 PATH,但这没有帮助。
这是脚本:
#!/bin/bash
/opt/local/bin/autossh -M 0 -f -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -o "ExitOnForwardFailure yes" -R 19990:localhost:22 mnewman@super.myddns.rocks -p 10000
我尝试过使用和不使用“ExitOnForwardFailure yes”
这是列表:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
</string>
</dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mgnewman.autossh</string>
<key>ProgramArguments</key>
<array>
<string>/Users/mnewman/bin/autossh.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
我尝试过使用和不使用 PATH 键。
我希望能够远程登录到这台机器。我也尝试过仅使用 ssh 并且它可以从命令行和 launchd 正常运行:
#!/bin/bash
ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R 19999:172.16.0.56:22 mnewman@super.myddns.rocks -p 10000
当然,由于 ssh 有效,我实际上并不需要 autossh,但我想知道为什么它不适合我。
【问题讨论】:
-
我已经设置了 StandardErrorPath 和 StandardOutPath,但是那里什么都没有。我也将 debug 设置为 true,但 system.log 中唯一的内容是:
-
我已经设置了 StandardErrorPath 和 StandardOutPath,但是那里什么都没有。我也将 debug 设置为 true,但 system.log 中唯一的内容是:
Jul 6 06:27:27 Axe com.apple.launchd.peruser.504[173] (com.mgnewman.autossh): Throttling respawn: Will start in 10 seconds我不知道还能做什么。
标签: bash ssh osx-mavericks launchd autossh