- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Monitoring a UNIX directory with alerting
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
06-06-2001 06:25 AM
06-06-2001 06:25 AM
can use to monitor a UNIX directory. I
want to use this script via crontab. I
want the script to look for a specific
file (abc.txt) in a specific directory
(/jeff/files). If this file is there,
do nothing. If this file is not there,
alert us (using email, page, other
alerting). Is this possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 06:34 AM
06-06-2001 06:34 AM
Re: Monitoring a UNIX directory with alerting
variable in an if statement.
if the return code is anything other than true
you would use mailx to mail a message.
I'm sure by the end of the day you'll have a hundred elegant ways to do it.
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 06:35 AM
06-06-2001 06:35 AM
Re: Monitoring a UNIX directory with alerting
whithin a script you can check for the file with eg.:
if [ ! -f /jeff/files/abc.txt ]
then
mailx -s 'File not found'
fi
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 06:38 AM
06-06-2001 06:38 AM
Re: Monitoring a UNIX directory with alerting
then
mailx -s "file not found" user@host fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 06:39 AM
06-06-2001 06:39 AM
SolutionYou could cron the following one-liner:
# [ -f /tmp/myfile ] && echo "alert!" |mailx -s "file present!" root
This would alert 'root' if /tmp/myfile is present.
If you want the alert to be if absent, do:
# [ -f /tmp/myfile ] || echo "alert!" |mailx -s "file present!" root
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 06:41 AM
06-06-2001 06:41 AM
Re: Monitoring a UNIX directory with alerting
Try this :cd /jeff/files
if [ $? -eq 0 ]
then
if [ -f abc.txt ]
then
mailx -s 'File found'
fi
fi
exit
I hope this help
Regards
Abel Berger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 06:41 AM
06-06-2001 06:41 AM
Re: Monitoring a UNIX directory with alerting
Try something close to this:
#!/usr/bin/sh
PATH=/usr/bin:${PATH}
export PATH
TARGET=/xxx/yyy/myfile
MAILTO="me@mycompany.com"
STAT=0
if [ ! -r "${TARGET}" ]
then
echo "File ${TARGET} missing." | mail ${MAILTO}
STAT=$?
fi
exit ${STAT}
Most pagers also have a SMTP interface so by changing ${MAILTO} you can also send a page.
One way to do it, Clay