No se puede ejecutar Bash Script en Cronjob en Mac

No se puede ejecutar Bash Script en Cronjob en Mac

El siguiente script se puede ejecutar desde un usuario normal, pero no puedo ejecutar el script a través de cronjob en macos (bigsur): el siguiente error aparece cuando el script se ejecuta a través de la seguridad del trabajo: SecKeychainSearchCopyNext: no se pudo encontrar el elemento especificado en el llavero

#!/bin/sh

keychainItem="connectvpn"
# this name has to match "Account" for the entry you make in keychain
VPNName="DIS CVPN"   # match the name of the VPN service to run
function isnt_connected () {
 scutil --nc status "$VPNName" | sed -n 1p | grep -qv Connected
}

get_pw () {
   security 2>&1 >/dev/null find-generic-password -ga $keychainItem \
   |ruby -e 'print $1 if STDIN.gets =~ /^password: "(.*)"$/'
}



echo "fetching VPN credentials from keychain account \"$keychainItem\""
echo "Using VPN service: $VPNName"

if isnt_connected $VPNName; then
 echo "Connecting to VPN..."
 scutil --nc start "$VPNName"
 sleep 1
 osascript -e "tell application \"System Events\" to keystroke tab"
 osascript -e "tell application \"System Events\" to keystroke \"$(get_pw)\""
 osascript -e "tell application \"System Events\" to keystroke return"
else
 echo "Already Connected to VPN..."
fi

Aquí está mi línea crontab:

*/1 * * * * /Users/demo/vpn/connect.sh >> /Users/demo/vpn/vpnlog.log 2>&1

información relacionada