Badblocks script against multiple drives


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Badblocks script against multiple drives
# 8  
Old 02-24-2017
Quote:
Originally Posted by cphillips
Robin,

I've used the concatenate option to merge all files and then send that resulting file. That's all worked ok.

However, I believe I need another "&" to make the whole process run in the background as it isn't doing that at present.. Where should I put it?!

Here's my script so far:

Code:
#!/bin/bash
for drv in {b..k};
do
           badblocks -v /dev/sd$drv > badblocks_$drv.out  &
done

wait

for logfile in badblocks_*.out
do
   echo "Logfile $logfile:"
   cat $logfile
   echo
done > all_badblocks.out

mail -s "Badblock Scan" me@mymail.uk < all_badblocks.out

Thanks for all the help, as you may have guessed, I've not done much bash scripting!
If your script is named blockchecker.sh
Code:
chmod +x blockchecker.sh
./blockchecker.sh &

# 9  
Old 02-24-2017
You may, of course, prefer to send the files individually as the scans finish, so this might be better because your script will finish and the process will carry on in the background:-
Code:
#!/bin/bash
for drv in {b..k};
do
   ( badblocks -v /dev/sd$drv > badblocks_$drv.out ; \
     mail -s "Badblock Scan of $drv" me@mymail.uk < badblocks_$drv.out ) &
done


Is that any better?
Robin
# 10  
Old 02-24-2017
Thanks Robin, that would be perfect.. Handy if I have different sized drives being tested. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script for viewing multiple logs from multiple server

I am new to Shell scripting and below is my requirement. I need to search some specific word e.g. "exception" or "transaction" from log file. We have multiple env e.g. Level1 , Level2 etc and each env have Multiple boxes e.g. For Level 1 env we have "test11.test.com" , "test12.test.com". Each... (1 Reply)
Discussion started by: peeyush
1 Replies

2. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

3. Solaris

Multiple Backups to USB 1TB Drives using dd

First of all, great web site! I have been using it for a while but just registered today. It's been a great resource for me. Now, on to my issue.;) I'm geographically separated from six (Sun v245s) development servers that I have been asked to backup and restore as development is done and... (11 Replies)
Discussion started by: ShawnD41
11 Replies

4. UNIX for Advanced & Expert Users

New Drives on Solaris 8

Hi All! I'm running Solaris 8(02/02) on a v880 with 6 internal drives and several SAN drives attached via HBA cards. My questions is this: Can I use devfsadm -C to see new SAN drives without rebooting? Thanks!! (2 Replies)
Discussion started by: bluescreen
2 Replies

5. Shell Programming and Scripting

BASH Script to Detect and List USB Flash Drives

Hello. This is my first post to this forum. I've read many of the posts over the last two or three years and I've learned a lot. I'm creating a live Linux distribution using the Linux Live Scripts -- just as a hobby project -- and I'm wanting to create an automated way for a user to copy the... (7 Replies)
Discussion started by: godzillarama
7 Replies

6. BSD

tape drives vs. tar with multiple directories

Hello, I have a little problem with backup & restoring files from tape drive. I am adding 3 directories to my tape, and it is OK: hades# tar -cvf /dev/nsa0 test test1 restore a test a test/level1 a test/myharddisk.img a test1 a test1/level1 a test1/myharddisk.img a test1/test.img a... (1 Reply)
Discussion started by: d3m00n
1 Replies

7. Shell Programming and Scripting

how floppy disks, CDs and flash drives (pen drives) are accessed in UNIX

hi how floppy disks, CDs and flash drives (pen drives) are accessed in UNIX? thanks (0 Replies)
Discussion started by: nokia1100
0 Replies

8. UNIX for Dummies Questions & Answers

detecting drives

I know that Unix is different from windows in that it needs more manual configuring but how do I get Solaris 8 (Intel version) to recognize my floppy drive and cd-rom?? I mean does it automatically detect the drives at startup and I have to mount them or do I have to create the drives somehow and... (1 Reply)
Discussion started by: eloquent99
1 Replies

9. IP Networking

mapping drives

how can i map a shared network drive? Is there any command to perform mapping? For example if i want to map a shared directory named "wwwroot" in machine "dev001" to my machine's "X" drive, how can it be done?? -Thanks Sakthi. (1 Reply)
Discussion started by: cs_sakthi
1 Replies
Login or Register to Ask a Question