- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script required to check the size of Directory
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 01:20 AM
тАО06-20-2011 01:20 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 01:24 AM
тАО06-20-2011 01:24 AM
Re: script required to check the size of Directory
du -kx /exaccess/AM1/access/oblix/logs
- Tags:
- du
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 01:29 AM
тАО06-20-2011 01:29 AM
Re: script required to check the size of Directory
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 01:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 01:39 AM
тАО06-20-2011 01:39 AM
Re: script required to check the size of Directory
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/?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 01:40 AM
тАО06-20-2011 01:40 AM
Re: script required to check the size of Directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 01:44 AM
тАО06-20-2011 01:44 AM
Re: script required to check the size of Directory
-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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 01:46 AM
тАО06-20-2011 01:46 AM
Re: script required to check the size of Directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 02:01 AM
тАО06-20-2011 02:01 AM
Re: script required to check the size of Directory
#!/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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 02:07 AM
тАО06-20-2011 02:07 AM
Re: script required to check the size of Directory
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 }'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 02:11 AM
тАО06-20-2011 02:11 AM
Re: script required to check the size of Directory
#!/bin/sh
cnt=0
cnt=`du -ks /tmp | awk '{ print $1 }'`
if [ $cnt -gt 1000 ]
then
opcmsg a=BAC o=EDMConnection msg_text="EDM Established Connection is $cnt" msg_grp=OpC s=major
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 02:13 AM
тАО06-20-2011 02:13 AM
Re: script required to check the size of Directory
You need to separate out the size from the path:
cnt=$(du -ks /tmp | awk '{print $2}')
(Assuming that the size is the second field.)
If you want Gb you can do the divide in awk:
cnt=$(du -ks /tmp | awk '{printf "%d", $2/(1024*1024)}')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 02:23 AM
тАО06-20-2011 02:23 AM
Re: script required to check the size of Directory
cnt=$(du -ks /tmp | awk '{printf "%d", $2/(1024*1024)}')
#!/bin/sh
cnt=0
cnt=$(du -ks /tmp | awk '{printf "%d", $2/(1024*1024)}')
if [ $cnt -gt 1000 ]
then
opcmsg a=BAC o=EDMConnection msg_text="The log level size exceeds 60 GB is $cnt" msg_grp=OpC s=major
fi
Output:
root@ggnems21 # sh EDMLogSize.sh
EDMLogSize.sh: syntax error at line 3: `cnt=$' unexpected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 02:31 AM
тАО06-20-2011 02:31 AM
Re: script required to check the size of Directory
Again, this is perfectly valid syntax for a real shell. What OS are you running?
You can replace $() by the archaic `` construct:
cnt=`du -ks /tmp | awk '{printf "%d", $2/(1024*1024)}'`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 02:32 AM
тАО06-20-2011 02:32 AM
Re: script required to check the size of Directory
SunOS ggnems21 5.10 Generic_142900-02 sun4v sparc SUNW,SPARC-Enterprise-T5120
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 02:38 AM
тАО06-20-2011 02:38 AM
Re: script required to check the size of Directory
#!/bin/sh
cnt=0
cnt=`du -ks /tmp | awk '{printf "%d", $2/(1024*1024)}'`
if [ $cnt -gt 1000 ]
then
opcmsg a=BAC o=EDMConnection msg_text="The log level size exceeds 60 GB is $cnt" msg_grp=OpC s=major
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 02:41 AM
тАО06-20-2011 02:41 AM
Re: script required to check the size of Directory
this is hp-ux forum...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2011 02:42 AM
тАО06-20-2011 02:42 AM
Re: script required to check the size of Directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2011 11:02 PM
тАО06-25-2011 11:02 PM
Re: script required to check the size of Directory
Use ksh instead of sh in your first line, this will fix it on solaris.
hth,
Stephan
How to find the right forum --> New forum location by ITRC tree
"we wouldn't call it code, if we could read it ..."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-01-2011 06:50 AM - edited тАО10-01-2011 06:51 AM
тАО10-01-2011 06:50 AM - edited тАО10-01-2011 06:51 AM
Re: script required to check the size of Directory
I know that 'du' isn't 'di', but I'd like to share this related tool ...
After maybe 40 mails with the author of di, I am glad to say that the just release new version 4.29 works on all HP-UX that I could access, ranging from 10.20 +DAportable to 11.31 with gcc/64
I have uploaded the depots to my site which should be in sync within 20 hours, so feel free to grab your copy. Some examples:
$ di -l -c s,m,b,u,v,p,T /dev/vg00/root,/,"400.0M","333.2M","66.3M",83%,vxfs /dev/vg00/data,/data,"12.0G","11.3G","0.6G",95%,vxfs /dev/vg00/home,/home,"512.0M","265.1M","246.9M",52%,vxfs /dev/vg00/opt,/opt,"6.5G","6.1G","0.4G",95%,vxfs /dev/vg00/pro,/pro,"24.0G","22.2G","1.8G",93%,vxfs /dev/vg00/stand,/stand,"304.0M","183.2M","119.9M",61%,vxfs /dev/vg00/tmp,/tmp,"2.0G","0.8G","1.2G",40%,vxfs /dev/vg00/usr,/usr,"5.3G","2.2G","3.1G",42%,vxfs /dev/vg00/var,/var,"4.5G","1.8G","2.7G",41%,vxfs /dev/vg00/wrk,/wrk,"1.0G","0.3G","0.6G",37%,vxfs $ di -c >di.csv $ env DBI_DSN="dbi:CSV:f_ext=.csv/r" qs -L f di w p '>' 90 SCHEMA: merijn, TABLE: di [.] select s, m, b, u, v, p, t from di where p > '90' s |m |b |u |v |p |t /dev/vg00/data|/data |12.0G|11.3G|0.6G|95%|vxfs /dev/vg00/opt |/opt |6.5G |6.1G |0.4G|95%|vxfs /dev/vg00/pro |/pro |24.0G|22.2G|1.8G|93%|vxfs $
qs is a perl script that acts as a command-line SQL query interpreter (qs = quick select), and used here just to demonstrate how easy the output of the new -c option for di is parsable.