Guten Tag liebe Linux jünger,
ich habe ein Problem mit einem kleinen Script von mir.
Wenn ich das Script von Hand starte läuft es gut durch und erkennt zuverlässig ob eine Ip erreichbar ist.
Wird das Script per crontab ausgeführt, wird immer nur zurück gegeben: keine IP erreichbar
Ich stehe da ein wenig auf dem Schlauch, da ich überhaupt keine Ahnung habe was das sein könnte.
Ich bin BASH Anfänger und an Linux habe ich mal gerochen. - reißt euch also bitte mit Abkürzungen zusammen
( https://github.com/JuXReal/SmartKey )
Code:
#!/bin/sh
#define the ip of the first device
if ping -c 1 192.168.0.107 &> /dev/null
then
handy1=1
echo 1
else
echo 0
fi
#define the ip of the secound device
if ping -c 1 192.168.0.109 &> /dev/null
then
handy2=1
echo 1
else
echo 0
fi
#now we calculate the status
status=$((handy1 + handy2))
if [ $status -eq 0 ]
then
#this will happend if no device were found
#example - my securitycam starts to Film the room
echo "17=0.2" > /dev/pi-blaster
else
#this will happend if one of the both device are online
#example - my secrutiycam turn around to face the wall
echo "17=0.3" > /dev/pi-blaster
fi
Mein cronjob:
Code:
* * * * * cd /home/pi/SmartKey && ./smartkey.sh
System:
Debian Whyzee - Raspberry pi
Lesezeichen