You are not logged in.
Pages: 1
I've written a script that periodically checks whether or not I'm connected to a VPN, and if I'm not it automatically connects me. It works perfectly when ran via the terminal, but when I schedule it with cronie it doesn't work.
My script: VPNautoconnect.sh
#!/bin/bash
#connects automatically to vpn
#@author Duriaux
#@date 2018-01-19
#Check if vpn is connected
#If not, connect
STR="$(nmcli con | grep -i vpn | grep -i wlp2s0)"
if [ "$STR" == "" ]; then
#Connect to VPN"
nmcli con up id "PIA - US Midwest"
fiMy cron file:
*/10 * * * * Duriaux /bin/sh /home/Duriaux/utils/VPNautoconnect.shThe script has been given the executable bit with chmod +x, and I've tested it to make sure cronie is actually running it by adding a line where it prints something to a text file in my home directory. It's definitely executing, but it doesn't connect to the VPN when run by cronie. Is there something specific to Arch or Cronie I'm overlooking?
Thanks in advance for any help,
Duriaux
Offline
Perhaps add the full paths to the commands you are using as environment variables aren't always propagated into cron.
Have you tried adding bash debugging ("set -x" for instance) into the script?
Offline
Pages: 1