I'm running Debian Squeeze/Testing and have this in my /etc/rc.local:
tail -f /var/log/syslog | awk '/kernel: sdb: sdb1/ {system("/bin/sleep 10; /sbin/hdparm -Y /dev/sdb")}' &
Whenever I insert a hard drive caddy I want the disc to be put into sleep mode until it's required. The drive is used only once every 24 hours to backup and the drive is changed each day.
However it doesn't work. If I remove a drive caddy and then replace it the relevant lines appear in syslog but the drive keeps spinning.
If I stop the current tail/awk processes, remove and replace the caddy then run /etc/rc.local from the command line it does work and the drive stops spinning.
I have now run out of expertise. Any suggestions please?