gpt4 book ai didi

linux - 使用 crontab 自动重启 SNX

转载 作者:太空宇宙 更新时间:2023-11-04 10:03:35 25 4
gpt4 key购买 nike

我正在使用 VPN 连接,使用 SSL Network Extender(SNX) 连接到远程服务器。来自远程服务器的连接仅限于 12 小时。之后连接被断开,必须重新启动 SNX 服务器。为了克服这些困难,我正在尝试使用 crontab 自动重启 SNX。

  1. 我已经创建了一个名为 vpn.sh 的 shell 脚本文件。
#!/bin/bash
snx -d
sleep 3
echo 'password' | snx
  1. 我在主目录中有配置文件调用 .snxrc
server server.com
username username
reauth yes
  1. 在 crontab (crontab -e) 中我有配置

* */12 * * * bash/home/username/vpn.sh >/home/username/cron.log

它每 12 小时运行一次。但是 snx -d 运行成功但到达 echo 'newpass6' | snx 我收到此错误:

初始化终端失败!

有人遇到过这样的问题吗?请帮我。我已经挣扎了一个星期了。提前致谢。

我已点击此链接进行设置 snx

最佳答案

因为没有终端就无法启动snx客户端。所以我将这些命令放入我的脚本中以在 byobu session 中启动 snx。

byobu new-session -d -s vpn;
byobu new-window -t vpn:1 -n "snx" "echo your_password | snx -s your_ip -u your_user; sleep 10"

关于linux - 使用 crontab 自动重启 SNX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54221762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com