The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Urgent : Help required V3l0 AIX 2 01-11-2008 11:37 AM
Urgent help required umanglalani Shell Programming and Scripting 1 04-12-2007 03:24 AM
Urgent Help required rahul26 UNIX for Dummies Questions & Answers 1 08-16-2006 01:23 PM
Urgent help required with uname() rm1 High Level Programming 2 02-23-2005 10:18 PM
C programming - Urgent help required kkumar1975 High Level Programming 2 04-08-2002 07:36 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-22-2009
julirani julirani is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 14
Unhappy Urgent help required

Hi All,
I am new to unix , Please help me regarding the below issue . my application's main pragram in "a.sh" and one upstream application sending a file daily via connect direct and then calling the script "a.sh" . But the condition in our apll. is no two thread can't run at a time. so there is a validation in "a.sh" but some times it showing the error "one thread running" but when i checked with ps-ef command..then it not satisfying the below condition .

Below is the code :


Code:
PROCESS=`ps -ef | grep "/appl/a.sh" | grep -v "grep" | wc -l`
 if [ $PROCESS -gt 2 ]
 then 
  echo "        ERROR:- One thread  is running "
  exit 1
 fi

Please help me .
Thanks in advance

Last edited by DukeNuke2; 04-22-2009 at 03:47 AM.. Reason: added code tags
  #2 (permalink)  
Old 04-22-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 457
Julirani,

I am not sure of the application process, but there is a possibility that there will be multiple instances of a.sh running , but the time u manually check it , the execution of script might be over.

Check in the remaining part of the script any infinite loops or conditions exist?..
  #3 (permalink)  
Old 04-24-2009
julirani julirani is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 14
Unhappy

Quote:
Originally Posted by panyam View Post
Julirani,

I am not sure of the application process, but there is a possibility that there will be multiple instances of a.sh running , but the time u manually check it , the execution of script might be over.

Check in the remaining part of the script any infinite loops or conditions exist?..



HI Panyam,
Thanks for your reply . Actually , it is strange , when i doing the grep using the below command
command:
ps -ef | grep "/appl/a.sh" | grep -v "grep"
output :
user 20169 20168 0 06:00:13 ? /bin/ksh /appl/a.sh
user 20168 1 0 06:00:13 ? 0:00 sh -c /appl/a.sh


But when i print the value of the var for the below command it showing diffrent .

command:
PROCESS=`ps -ef | grep "/appl/a.sh" | grep -v "grep" | wc -l`
echo $PROCESS

output :
4


But the output always not the same .some thimes it showing the correct value i.e 2 .



So i am unable to find the root cause . Is it any problem with the OS ?
Could you please help me regarding this.


Thanks in advance .
  #4 (permalink)  
Old 04-24-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 457
Hi julirani,

I am sure there will be no problem with the OS. Make sure that only one instance of the script "a.sh" is runnning . Your command returnning value 4 since it might found multiple instances of the same.Of course you may not be the one who is running the script once again . Ther might be others in the server who is running.
Sponsored Links
Closed Thread

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 07:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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