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
one question for bash shell script zx1106 Shell Programming and Scripting 9 03-10-2008 12:40 AM
Bash scripting question re: newlines retrovertigo Shell Programming and Scripting 4 07-06-2007 01:44 PM
quick newbie bash question redsand9009 Shell Programming and Scripting 4 01-25-2007 03:44 AM
awk / bash globbing question franzke Shell Programming and Scripting 3 07-15-2005 12:55 AM
BASH shell script question ewarmour Shell Programming and Scripting 3 05-24-2002 06:10 AM

 
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 06-18-2008
itik itik is offline
Registered User
  
 

Join Date: Oct 2007
Location: Toronto, Ontario
Posts: 354
bash question

Hi Guys,

I found this script for monitoring the status of a services:

for i in syslogd cron; do
if [ `ps -eo comm | grep -v grep | grep -c ^$i` -gt 0 ] && [ `ps -eo comm,s|grep -v grep|grep ^$i|awk '{print $2}'|sort -u` = "A" ];
then
printf "%-8s" "$i";printf " is alive=A\n"
else
printf "%-8s" "$i";printf " is not alive\n"
fi

The script is working fine except if either syslogd or cron will have a defunct on the memory. It will have an error like this:

/usr/local/bin/checkserver.sh: line 9: [: too many arguments
syslogd is not alive

But of course, syslogd is running if I check with ps -ef | grep syslogd:

[itik@north001 ~]$ ps -ef|grep syslogd
root 1234 1 0 May04 ? 00:11:42/usr/sbin/syslogd
root 18555 5525 0 May04 ? 00:00:00 [syslogd] <defunct>
itik 22417 19840 0 13:23 pts/1 00:00:00 grep syslogd

Without error the output is like this:

cron is alive=A
syslogd is alive=A


Can someone please let me know where to change the error?

Thank you in advance.

Best Regards,
itik
 

Bookmarks

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 05:01 PM.


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