Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with script

Status
Not open for further replies.

SLG

MIS
Dec 19, 2001
106
US
I have a problem with my USB drives spinning down so I wrote a simple script that would 'touch' a file and copy it every minute to keep the drives alive. Now I want to take it one step further. I would like the script to check if the drive is mounted, if not try to mount it, then write to it and if it doesn't work send me an email. ;-)
It has been 10+ yrs since I wrote a complicated shell script and I need a little help.
Thanks in advance!
 
This is a ksh script on top of my head as i don't have a machine to test it :)

Code:
df -h | grep usb_mount
if [[ $? -ne 0 ]]
then
mount /usb_mount
touch /usb_mount/testing
if [[ $? -ne 0 ]]
then
cat Drive was dismounted > /tmp/temp.out
mail -s "Drive dismounted" "your_email@domain" < /tmp/temp.out
fi
fi

Regards,
Khalid
 
Great, I'll try it and let you know.
 
Have you tried hdparm or sdparm to disable the spin down?
I can't try it at the moment, but you should be able to change the behaviour.


&quot;If you always do what you've always done, you will always be where you've always been.&quot;
 
Yes. The spin down is hard coded into the drive so sdparm does not work. >:-<
I've been struggling with this for a few months now and I'm about the scrap the whole drive.
About every few days the USB drive will 'hiccup' and starts throwing I/O errors. I have my touch scripting running as well as the script above but it doesn't seem to matter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top