Ich habe ein kleines Bashscript, dass alle x Minuten per crontab aufgerufen wird, das geht auch alles, bis auf die Tatsache, dass das reboot nicht funktioniert, wenn ich nicht sudo reboot schreibe, obwohl der crontab -e als root installiert wurde, auch absolute Pfade helfen nicht.
Hier das Bashscript wie es funktioniert:
Bash
#!/bin/bash
host -4 abcd.efghn.mn | cut -c1-25 > /dev/shm/host.txt
DATA=$(cat /dev/shm/host.txt | cut -c1-25)
echo $DATA
if [ "$DATA" = "abcd.efghn.mn has address" ]
then
echo OK
else
echo Nicht OK
sudo reboot
fi
Display More
Woran kann das liegen ?
EDIT: Hat sich erledigt, muss mich wohl vertippelt haben, geht auch so:
Bash
#!/bin/bash
/usr/bin/host -4 abcd.efghn.mn | /usr/bin/cut -c1-25 > /dev/shm/host.txt
DATA=$(/bin/cat /dev/shm/host.txt | /usr/bin/cut -c1-25)
/bin/echo $DATA
if [ "$DATA" = "abcd.efghn.mn has address" ]
then
/bin/echo OK
else
/bin/echo Nicht OK
/sbin/reboot
fi
Display More