Operating System - HP-UX
1748274 Members
4423 Online
108760 Solutions
New Discussion юеВ

Re: script required to check the size of Directory

 
SOLVED
Go to solution
mjoshi
Trusted Contributor

script required to check the size of Directory

Required a script which will show the status for my : /exaccess/AM1/access/oblix/logs directory.

Once the size gets exceed to 60 GB

i.e if size for this exceeds to 60 GB then it shows the size else not.


With regards,
Mjoshi
19 REPLIES 19
Dennis Handly
Acclaimed Contributor

Re: script required to check the size of Directory

The following will give the size in 1Kb blocks:
du -kx /exaccess/AM1/access/oblix/logs
mjoshi
Trusted Contributor

Re: script required to check the size of Directory

Thanks Dennis, But i need in GB itself.

Though the cmd is failing :
du: illegal option -- x
usage: du [-a] [-d] [-h|-k] [-r] [-o|-s] [-H|-L] [file ...]

du -kx /exaccess/AM1/access/oblix/logs

Plz verify the cmd once again
g3jza
Esteemed Contributor
Solution

Re: script required to check the size of Directory

Hi,
du does not have the option to give the output in MB/GB. So you need to calculate it... or make an alias for the 'du' command.

to report size in KBytes:
du -ks /your/path
Dennis Handly
Acclaimed Contributor

Re: script required to check the size of Directory

>I need in GB itself.

Once you get the value in Kb, you can divide by 1 Mb to get Gb.

>Though the cmd is failing: du: illegal option -- x

du -x is perfectly valid under HP-UX. Or are you using a foreign devil du under /usr/local/bin/?
mjoshi
Trusted Contributor

Re: script required to check the size of Directory

du -ks is working...

Dennis Handly
Acclaimed Contributor

Re: script required to check the size of Directory

>du -ks is working.

-x is only needed if you wanted to make sure you didn't cross any mount points. In your case probably not likely so deep in your directory hierarchy.
g3jza
Esteemed Contributor

Re: script required to check the size of Directory

Dennis: Hmm, I didn't even know about the '-x' option, it can be quite useful...
mjoshi
Trusted Contributor

Re: script required to check the size of Directory

If i use for my scripting then is this script correct:

#!/bin/sh
cnt=0
cnt=`du -ks /tmp`
if [ $cnt -gt 1000 ]
then
opcmsg a=BAC o=EDMConnection msg_text="EDM Established Connection is $cnt" msg_grp=OpC s=major
fi



as i am facing an error while running it :

root@ggnems21 # sh logsize.sh
logsize.sh: test: unknown operator /tmp

g3jza
Esteemed Contributor

Re: script required to check the size of Directory

Well,
you need to pipe the du with some text editing tool, as du -ks /tmp also shows the '/tmp'. So something like this, if you want only number of kbytes from the du -ks output:

du -ks /tmp | awk '{ print $1 }'