- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help on Shell script
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-11-2002 11:54 PM
02-11-2002 11:54 PM
Can you please help me in writing a shell script for continously monitoring the syslog file for certain errors and if that error occurs then execute a particular command.
Thanks
Sudhakaran.S
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 12:03 AM
02-12-2002 12:03 AM
Re: Help on Shell script
You can use tail -f
I prefer a cron job that executes at n times per day and then just greps for the errors.
For example, my backup write this into the syslog:
Feb 12 02:01:48 melhpor1 syslog: INFO: LVM backups for host
..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 12:14 AM
02-12-2002 12:14 AM
Re: Help on Shell script
You need to write a script that looks
at the /var/adm/syslog/syslog.log
file. In doing so you will need to
describe the errors or warnings that
you may be looking for. So at given
times of the day using cron, use
tail -f xxxx lines and grep for the
errors you might be looking for.
-Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 12:28 AM
02-12-2002 12:28 AM
Solutionanyway....
an exmaple would be:
#!/bin/sh
SCRIPT=${0##*/}
PATH=/bin:/sbin:/usr/bin:/whatever
if grep -q
if you're feeling artistic, put the error lines into a file and do something like this:
#!/bin/sh
#########################################################
#
# Short script to check for oracle databases
# Nothing fancy
# Has $basename.conf file to add database name to
#
#
# v1.00 22/5/01
#
# Scott van Kalken
#########################################################
######################################################
# Couple of variables - only the essentials man #
######################################################
SCRIPT=${0##*/}
CONF=/opt/admin/morning_checks/$SCRIPT.conf
PATH=/usr/bin:/opt/admin/morning_checks
#####################################################
# Functions
#
# Function go checks everything that needs to be
#
#####################################################
go(){
while read database
do
dbup=`ps -ef | grep -v grep | grep -c ora_pmon_$database`
if [ $dbup -eq 0 ]
then
echo $database IS NOT UP
else
echo $database IS UP
fi
done
}
###########################################################
#
# Main Script - if no conf file then blat out
#
###########################################################
if [ ! -f $CONF ] ; then echo "No Conf File" ; exit 1; fi
go < $CONF
This is a script to check whether or not oracle databases are up in the morning after cold backup.
Although we're moving to hot backup, it's still nice to see that they're at least up.
I'm thinking of something neat to test test for actual functionality in version 59.1 :)
Anyhow, hope this helps get you started.
Scott.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 04:28 AM
02-12-2002 04:28 AM
Re: Help on Shell script
the following script could do the job for you:
tail -n 5 /var/adm/syslog/syslog.log > /path_to_logfile
# output of tail is written into logfile
grep 'error_message' /path_to_logfile
#grep looks for error_message
if test $? -eq 0
then
command_to_be_done_in_this_case
fi
# if found, then command is executed
You simply have to put this script as cronjob, done as often as you need!
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2002 07:04 AM
02-13-2002 07:04 AM