- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Scripting Assistance
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
тАО07-30-2007 08:12 AM
тАО07-30-2007 08:12 AM
Scripting Newbie here. Just looking for a little script to monitor a specific file; when this file goes over a certain size (NOT percent used as in a bdf script), it will send an email. Thanks in advance.
Jay
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 08:29 AM
тАО07-30-2007 08:29 AM
Solution------------------------------
#!/usr/bin/sh
typeset FNAME=/aaa/bbb/myfile
typeset -i MAXSIZE=1000000
typeset ADDRESS="mickey@mouse.com"
typeset SUBJECT="Filesize Notification"
typese SZ=""
export PATH=${PATH}:/usr/bin
if [[ -f "${FNAME}" ]]
then
SZ=$(ls -l "${FNAME}" | awk '{print $5}')
if [[ ${SZ} -gt ${MAXSIZE} ]]
then
echo "File ${FNAME} size ${SZ} bytes." | mailx -s "${SUBJECT}" ${ADDRESS}
fi
fi
-----------------------------------------
- Tags:
- cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 08:29 AM
тАО07-30-2007 08:29 AM
Re: Scripting Assistance
#!/usr/bin/sh
FILEDIR=/my/file/path
FILENAME=myfile
FULLPATH=${FILEDIR}/${FILENAME}
WARNSIZE=1024c
FOUND=$(find ${FILEDIR} -name ${FILENAME} -size +${WARNSIZE})
if [ "${FULLPATH}" = "${FOUND}" ]
then
mailx -s "${FULLPATH} Warning" username@company.com <
EOM
fi
Obviously, change the dummy values and adjust the WARNSIZE value to fit your needs. Schedule to run via cron at the desired interval.
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 08:36 AM
тАО07-30-2007 08:36 AM
Re: Scripting Assistance
# ll -art file_name | awk '$5 > 1048576'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 08:48 AM
тАО07-30-2007 08:48 AM
Re: Scripting Assistance
# cat ./monitor
#!/usr/bin/sh
typeset -i SIZE=$1
typeset -i CURR=0
typeset FILE=$2
while true
do
CURR=`wc -c < ${FILE}`
if [ ${CURR} -gt ${SIZE} ]; then
mailx -s "${FILE} is larger than ${SIZE} characters" root < /dev/null
exit
fi
sleep 10
done
...Run as:
# ./monitor 1000 myfile
...that is, pass the maximum size in characters you want the file to grow to until an email alert is generated (here, to 'root') along with the name of the file that you want monitored.
Regards!
...JRF...
- Tags:
- sleep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 08:51 AM
тАО07-30-2007 08:51 AM
Re: Scripting Assistance
I maeant to add:
Adjust the loop timer as you see fit and run the script as a background process or eliminate the loop ('while true') and simply 'cron' the script to run periodically.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 09:27 AM
тАО07-30-2007 09:27 AM