PDA

View Full Version : Brauche Hilfe beim Festplatten Spindown


Baron1971
03-02-2008, 11:31
Hallo,
ich habe folgenden Beitrag zum Festplatten Spindown gelesen:
http://wl500g.info/showpost.php?p=47135&postcount=10

Soweit so gut. Meine externe Platte wird unterstützt, und wenn ich folgenden Befehl ausführe, legt sie sich auch schlafen:
/usr/local/sbin/scsi-stop /dev/scsi/host0/bus0/target0/lun0/disc

Wenn ich allerdings das angegebene Skript mit:
./scsi-stop.sh /dev/scsi/host0/bus0/target0/lun0/disc &

ausführe, bekomme ich folgende Fehlermeldung:
$ ./scsi-stop.sh: ./scsi-stop.sh: 39: Syntax error: end of file unexpected (expecting "done")

Kann mir bitte mal jemand sagen, was das für eine Fehlermeldung ist? Ich bin bei Linux leider eine ziemliche Flasche!

wengi
03-02-2008, 11:34
Hi,

könnte es sein, dass Du das done in der letzten Zeile vergessen hast?#!/bin/sh
if /usr/bin/[ $# -ne 1 ]; then
/bin/echo 1>&2 "Usage: $0 <device>"
exit 1
fi

PERIOD=30
BOUNDARY=1200
SCSISTOP=/usr/local/sbin/scsi-stop
LOGFILE=/tmp/scsi-stop.log

searchstr="disk_io:"
devaddr="(`/bin/ls -l $1 | /usr/bin/awk '{print($5 int($6/16))}'`)"

str=`/bin/grep "$searchstr" /proc/stat | devaddr="$devaddr" /usr/bin/awk -v 'RS= |\n' -F : '{ if($1==ENVIRON["devaddr"]) print($2) }'`
cooltime=0
stopped=0

while /bin/true; do
/bin/sleep $PERIOD
newstr=`/bin/grep "$searchstr" /proc/stat | devaddr="$devaddr" /usr/bin/awk -v 'RS= |\n' -F : '{ if($1==ENVIRON["devaddr"]) print($2) }'`
if /usr/bin/[ "$newstr" = "$str" ]; then
cooltime=$(($cooltime + $PERIOD))
if /usr/bin/[ $cooltime -ge $BOUNDARY -a $stopped -eq 0 ]; then
$SCSISTOP $1
time=`/bin/date '+%b %e %H:%M:%S'`
/bin/echo "$time: Cooled down..." >> $LOGFILE
stopped=1
fi
else
if /usr/bin/[ $cooltime -ne 0 ]; then
time=`/bin/date '+%b %e %H:%M:%S'`
/bin/echo "$time: Disk first used after $cooltime seconds" >> $LOGFILE
fi
cooltime=0
str=$newstr
stopped=0
fi
done

Baron1971
03-02-2008, 12:22
Das wars! Ich hatte nach done nicht enter gedrückt!
Es funktioniert.
Muss eigentlich das "./scsi-stop.sh /dev/scsi/host0/bus0/target0/lun0/disc &" in die Post-Boot eingetragen werden, damit es nach einem Router neustart wieder funktioniert?
Wenn ja wie?

wengi
03-02-2008, 19:20
Hi,

ich vermute mal, dass post-boot reichen sollte.

wengi