Xiè*_*léi 2 debian upstart ssh-tunnel redhat-enterprise-linux
我有一个新贵服务定义为:
/etc/init/sshproxy.conf
description "Lenik's secret tunnel thru *.ssh.myserver.com"
author "??? (Lenik)"
start on (net-device-up IFACE!=lo)
stop on runlevel[!2345]
script
# -T disable pseudo-tty allocation
# -f go to background after login but before command exec
# -n stdin from /dev/null, must be used when ssh is run in bg.
# -N no command
# -D "dynamic" app-level port forwarding.
sudo -usshproxy ssh -qTfn -ND *:7878 ssh.myserver.com
end script
Run Code Online (Sandbox Code Playgroud)
但是 ssh 隧道在几个小时后似乎变得僵化了,所以我想每小时重新启动它,如何在这个 .conf 文件中执行它,或者我应该编写另一个 cron.hourly 作业?
虽然“按时间间隔生成的事件”是Upstart 中的一项计划功能,但尚未准备好提供。所以你应该写一个像这样的简单脚本:
#!/bin/sh
service sshproxy restart
Run Code Online (Sandbox Code Playgroud)
并将其放入/etc/cron.hourly
文件夹。不要忘记设置一个可执行位 ( chmod +x /etc/cron.hourly/whatever.sh
),否则它不会启动。