- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script is not working, need your help.
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
03-22-2006 02:03 AM
03-22-2006 02:03 AM
Script is not working, need your help.
The script runs every minute through CRON from 1 to 5 am.
The script works fine if I manually assign values for HRMM=01:00 variable, but will not work with runtime values.
The script returns a â 0â value even error exists.
#!/usr/bin/sh
LOGS=/psoft/hr88/appserv/RPHRMS/LOGS
HRMM=`date +%H:%M`
#HRMM=01:00
logdate=`date +%m%d`
mytime=0
mytime=`awk '/java.net.ConnectException/ && (substr($3,1,5) == "'"$HRMM"'") {n++}; END {print n+0}' $LOGS/APPSRV_${logdate}.LOG`
if [[ $mytime -ne 0 ]]; then
echo "WebServer is down"| mailx -s "WebServer Down $(date +%Y%m%d' '%H:%M)" gulam@peelsoft.ca
fi
exit 0
Thanks,
Gulam.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2006 05:44 AM
03-22-2006 05:44 AM
Re: Script is not working, need your help.
awk has an option -v to set a variable outside of the script so it can be used in the script.
You might try the following-
mytime=`awk -v HRMM=$HRMM '/java.net.ConnectException/ && (substr($3,1,5) == HRMM) {n++}; END {print n+0}' $LOGS/APPSRV_${logdate}.LOG`
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2006 05:53 AM
03-22-2006 05:53 AM
Re: Script is not working, need your help.
mytime=`awk '/java.net.ConnectException/ && (substr($3,1,5) == "'"$HRMM"'") {n++}; END {print n+0}' $LOGS/APPSRV_${logdate}.LOG`
with this:
echo "HRMM " $HRMM > tmpfile
cat $LOGS/APPSRV_${logdate}.LOG >> tmpfile
awk '/HRMM/{myhrmm=$2;};/java.net.ConnectException/{if (substr($3,1,5) == myhrmm) {n++}; END {print n+0}' < tmpfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2006 08:13 PM
03-22-2006 08:13 PM
Re: Script is not working, need your help.
please add set -x at the topo of the script and post the output.
I don't think that the problem was the way you are using HRMM, because awk get it fine in both way:
/tmp/>HRMM=01:00
/tmp/>awk 'BEGIN {print "'"$HRMM"'"}' 01:00
/tmp/> HRMM=`date +%H:%M`
/tmp/>awk 'BEGIN {print "'"$HRMM"'"}' 04:12
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2006 08:39 PM
03-22-2006 08:39 PM
Re: Script is not working, need your help.
Or change this line in script and try. Are you getting that mail atleast?
if [[ $mytime -ne 0 ]]; then
echo "WebServer is down"| mailx -s "WebServer Down $(date +%Y%m%d' '%H:%M)" gulam@peelsoft.ca
else
echo "WebServer is running fine" | mailx -s "WebServer is running fine $(date +%Y%m%d' '%H:%M)" gulam@peelsoft.ca
fi
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2006 08:48 PM
03-22-2006 08:48 PM
Re: Script is not working, need your help.
HRMM=01:00
will not send mails b'cas no data availale in the log file to provide that. Try to change it as,
HRMM=01:12
will send mails.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2006 01:22 AM
03-23-2006 01:22 AM
Re: Script is not working, need your help.
When I traced it with -x, I found that there was 1 minute difference between log messages and cron/system time. I changed my checking time one minute behind (-1) and everything starting working as expected.
Thanks,
Gulam.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2006 01:22 AM
03-23-2006 01:22 AM
Re: Script is not working, need your help.
Gulam.