bash – Shell脚本没有通过crontab运行,但手动运行正常

我有一个脚本检查pptp vpn是否正在运行,如果不是,它重新连接pptp vpn,当我手动运行脚本时它执行正常,当我设置一个cron作业时,没有运行
* * * * * /bin/bash /var/scripts/vpn-check.sh

脚本来了:

#!/bin/sh
/bin/ping -c3 192.168.17.27 > /tmp/pingreport
result=`grep "0 received" /tmp/pingreport`
truncresult="`echo "$result" | sed 's/^\(.................................\).*$$'`"
if [[ $truncresult == "3 packets transmitted,0 received" ]]; then
/usr/sbin/pppd call home
fi
最后我找到了一个解决方案…我需要运行cron而不是
crontab -e

它需要运行

nano /etc/crontab

有类似的东西

*/5 *     * * *   root  /bin/bash /var/scripts/vpn-check.sh

现在很好!

谢谢大家的帮助……希望我的解决方案也能帮助其他人.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...