- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: file size alert
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
Forums
Discussions
Discussions
Discussions
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
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
02-13-2003 08:21 AM
02-13-2003 08:21 AM
Does anybody know of a script which will send me an email when a file reaches a certain size. we need to know when a dump file nears 2GB.
Any ideas ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2003 08:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2003 08:52 AM
02-13-2003 08:52 AM
Re: file size alert
/usr/bin/ksh
FFILE=/somepath/somefile
FSIZE=`ll $FFILE|awk '{ print $5 }'`
CSIZE=`echo $FSIZE/1048576|bc`
if test "CSIZE" -gt "2048"
then
echo "$FFILE is now larger than 2GB"|mailx -s "$FFILE Size error" root@yourhost
fi
Dividing FSIZE by 1045876 gets around the fact that the test command freaks out when dealing with numbers larger than 2,147,483,647 (2^30-1).
You could put this in a continuous loop by and not using cron by inserting the above lines between:
while true
do
.......(insert above lines here)
.......sleep 60 (or some other number)
done
Good Luck
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2003 08:55 AM
02-13-2003 08:55 AM
Re: file size alert
#1
while true
do
SIZE=ll /etc/fstab|cut -c 35-44
if [[ $SIZE -ge ##### ]]
then
cat warningmessagefile |sendmail -v you@your.mail
break
fi
done
this will constantly till the file passes the limmit you set (#####) then mail you 1x and stop
or you can make a cron job
SIZE=ll /etc/fstab|cut -c 35-44
if [[ $SIZE -ge ##### ]]
then
cat warningmessagefile |sendmail -v you@your.mail
fi
and schedule it to run at whatever intervals you like
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2003 09:08 AM
02-13-2003 09:08 AM
Re: file size alert
EMAIL=your_email@domain
FILE=your_file_name
LIMIT=1500000000
SIZE=`ls -l $FILE|awk '{ print $5 }'`
if [ $SIZE -gt $LIMIT ]
then
mailx -s "Message Subject" $EMAIL < /dev/null
fi
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2003 09:41 AM
02-13-2003 09:41 AM
Re: file size alert
#!/usr/bin/sh
FILE="your_file"
MAX=2000000 # 2 gig measured in kbytes
SIZE=`du -sk $FILE`
if [ $SIZE -ge $MAX ] ; then
echo "$FILE too large"
fi
You might want to change max size to catch before it actually reaches 2 gig, maybe 1990000. You could cron this script every couple of minutes.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2003 09:45 AM
02-13-2003 09:45 AM