The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to make your bash script run on a machine with csh and bash npatwardhan Shell Programming and Scripting 3 11-19-2008 04:17 AM
passing variable from bash to perl from bash script arsidh Shell Programming and Scripting 10 06-04-2008 01:25 PM
what's wrong with my bash script? ikk Shell Programming and Scripting 4 02-22-2008 12:55 AM
Problem with Unix script to start remote Tomcat shrgh Shell Programming and Scripting 2 02-08-2008 08:23 AM
Bash passes flags to shell wrong andyj Shell Programming and Scripting 7 07-07-2003 04:01 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-04-2009
quyennd quyennd is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 1
Please help to fingure out what wrong with my tomcat restarting bash script

Hi, I am a nbee to Unix, I have used following script to check my tomcat is running or not and restart if it down. but actually it restart my tomcat each time running even my tomcat still running fine:

Script that can run a check and perform an action if the check fails

/root/commandchecker.sh (get from http://downloads.rimuhosting.com/commandchecker.sh)

/root/istomcatrunning.sh:
code:
#!/bin/bash
tomcatpids=`ps axf --width=200 | grep "\-D[j]ava.endorse" | sed 's/^ *//g' | cut -d ' ' -f 1`
if [ -z "$tomcatpids" ]; then
# return a 'fail' code
return 1
fi
return 0

/root/restarttomcat.sh:
Code:
#!/bin/bash
# try to be nice
/etc/rc.d/init.d/tomcat stop
# but sometimes more drastics measures are necessary if things are not responding
kill -9 `ps axf --width=200 | grep "\-D[j]ava.endorse" | sed 's/^ *//g' | cut -d ' ' -f 1`
/etc/rc.d/init.d/tomcat start

cron job.

/etc/cron.d/monitortomcat.cron
0-59/5 * * * * root /root/commandchecker.sh --email youremail@example.com --command "/root/istomcatrunning.sh" --onfail "/root/restarttomcat.sh" --triggeractionafternfails 3 --checkname tomcatcheck > /dev/null"


The error I get when script run:
/root/istomcatrunning.sh: line 5: return: can only `return' from a function or sourced script
/root/istomcatrunning.sh: line 7: return: can only `return' from a function or sourced script
failed command result match (25 recently) for '/root/istomcatrunning.sh' expecting ''. recode=1
taking some action: /root/restarttomcat.sh
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
startup taking too long, not getting a response on The UNIX and Linux Forums - Learn UNIX and Linux from Experts, giving up
command result mismatch for /root/istomcatrunning.sh, sending email

Could anyone help to fingure out what wrong with the script please?

Thx a lot.
Quyen Nguyen.
 

Bookmarks

Tags
restart tomcat script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0