LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-25-2010, 10:38 AM   #1
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Rep: Reputation: 39
Feedback on a script


Hi there --

I am writing a script, based on one from an older UNIX reference guide, that is meant to check the size of a series of folders, and if any exceed a defined size, the administrator will be notified via e-mail.

The syntax of the script is currently the following:

Code:
#!/bin/bash
# check folder size

clinics='ls -1 /CMS/xiodata'
limit=80000

for clinic in $clinics
do 
	diskuse='du -hcs /CMS/$clinics  | awk '{print $1 }' -`
	if [ $diskuse -gt $limit ] 
	then
		/bin/mailx -s Clinic Folder Size admin@company.com <<!

System Administrator --

The folder size of the $clinic is over the $limit. Investigate the matter
further to determine what steps need to be done to correct this issue. 

! 
	fi
done
I had some questions that hopefully I could get feedback:

1. The limit= line sets the amount 80000 blocks. What would the syntax be to set the amount to 400 gigabytes.

2. Should the clinics= line read as-is, or should the syntax be the following:

Code:
clinics='ls -lh /CMS/xiodata'
Thanks.
 
Old 01-25-2010, 05:26 PM   #2
bmxcess
Member
 
Registered: Jan 2009
Location: Brisbane, Australia
Distribution: @work:RHEL 5.4/Fedora 13, @home:slack64-current,ubuntu lynx studio
Posts: 65

Rep: Reputation: 19
Sorry, should not have replied so quick [EDIT]

Perhaps a perl script would be better suited for your task? ie:

#!/usr/bin/perl
open( PIPE, "du -hcs /CMS/$clinics|" ) or die "Couldn't read pipe: $!";
while ( <PIPE> ) {
my( $f1, $f2 ) = split ' ', $_;

if($f1 =~ /G/) {
# do something with gigs
}
if($f2 =~ /M/) {
# do something with megabytes
}

}
close(PIPE);

Last edited by bmxcess; 01-25-2010 at 05:51 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables script feedback fotoguy Linux - Security 1 09-22-2005 02:11 AM
gateway, script feedback ... phoeniXflame Linux - Networking 1 10-06-2003 07:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration