I have a pptp VPN link dialing from my (debian) linux server here, to an ISA2003 server at a remote site.
The internet connection at (both) ends is somewhat dodgy, so I have written a little script to call pon myvpnlink
if it detects the link has gone down.
This script works fine if I run it from the CLI, but if its called via cron then the pon call seems to fail.
I have re-written this in both bash and perl and have the same problem with each. The script is executed, it can tell if the VPN link is currently up or down, it calls pon
which calls pppd, which fails to connect. If I then go an execute the script from the CLI its fine.
Any thoughts would be very much appreciated -this is doing my box in now.
#Syslog (on a failure):
Dec 30 17:02:01 LogServer /USR/SBIN/CRON[4530]: (root) CMD (/bin/bash /root/scripts/vpnup.bash >> /root/scripts/vpn.log)
Dec 30 17:02:01 LogServer pppd[4542]: pppd 2.4.4 started by root, uid 0
Dec 30 17:02:01 LogServer pppd[4542]: Couldn't get channel number: Input/output error
Dec 30 17:02:01 LogServer pppd[4542]: Exit.
#Cron Line
* * * * * root /bin/bash /root/scripts/vpnup.bash >> /root/scripts/vpn.log
Update:
Works fine now. I was calling my cron entry via /etc/cron.d/vpn which originally looked like:
MAILTO=root
* * * * * root /bin/bash /root/scripts/vpnup.pl >> /root/scripts/vpn.log
Now that its been changed, pptp works perfectly :-D
MAILTO=root
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * * root perl /root/scripts/vpnup.pl >> /root/scripts/vpn.log
many thanks to Justin for giving examples :)