I have a very simple bash script that checks if a vpn symlink exists and then complains if it doesn’t and it works just fine when ran from the prompt but for some reason the VPN variable remains empty when the script runs from cron. (vpn is named dynamically so can’t hardcode it)
I ran a find / >log from the script and it did show the /sys/class/net path so it shouldn’t be a file/selinux permission thing, it’s just not setting the variable.
Also tried VPN=find between ` as opposed to $(find) but that made no difference.
Both worked from the command line though.
#!/bin/bash
VPN=$(/usr/bin/find /sys/class/net/ -mindepth 1 -maxdepth 1 -name *vpn*)
if ! [ -L "$VPN" ] ; then
echo "VPN down! $VPN"
fi