Sponsored Content
Operating Systems AIX multipe shells spawned with "ps" command Post 87028 by johnnieb on Wednesday 19th of October 2005 10:04:56 AM
Old 10-19-2005
multipe shells spawned with "ps" command

I have a small function that I use to see if another version of the script is currently running. Occasionally, about 10% of the time, it reports that two instances of the script are currently running. Since I am using a unique name, I know that there is not another version running out there by another user.

I created a test script to capture some data. It appears as though "ps" is occasionally spawning a child shell. I have run the same test script on other AIX servers and have not been able to repeat it on them.

**********
AIX LEVEL
**********
/tmp>/usr/bin/rpm -qa | grep AIX
AIX-rpm-5.2.0.40-1

**********
TEST SCRIPT
**********
#!/usr/bin/sh
function p_check
{
PGM=$1
##myCNT=$(ps -ef | tee junk | grep -v grep | grep -c $PGM)
myCNT=$(ps -ef | tee junk | grep $PGM | grep -v grep | wc -l | awk '{print $1}')
rc=$?

if [[ $myCNT != "1" ]]; then
echo "$PGM is already running.($myCNT)"
echo "rc = $rc"
exit 100
fi
}

p_check "checkPS2.sh"


********************
OUTPUT FROM SCRIPT
********************
tmp>checkPS2.sh
tmp>checkPS2.sh
tmp>checkPS2.sh
checkPS2.sh is already running.(2)
rc = 0


************************************
SEARCH OF OUTPUT FILE (when problem occurs)
************************************
tmp>grep checkPS junk
edat 10618 36204 1 09:50:57 pts/0 0:00 /usr/bin/sh checkPS2.sh
edat 36204 17852 1 09:50:57 pts/0 0:00 /usr/bin/sh checkPS2.sh
edat 51188 10618 0 09:50:57 pts/0 0:00 grep checkPS2.sh

tmp>grep pts\/0 junk
UID PID PPID C STIME TTY TIME CMD
edat 17852 28470 0 15:36:44 pts/0 0:00 -ksh
edat 36204 17852 1 09:50:57 pts/0 0:00 /usr/bin/sh checkPS2.sh
edat 10618 36204 1 09:50:57 pts/0 0:00 /usr/bin/sh checkPS2.sh
edat 48266 10618 0 09:50:57 pts/0 0:00 tee junk
edat 51188 10618 0 09:50:57 pts/0 0:00 grep checkPS2.sh
edat 16540 10618 3 09:50:57 pts/0 0:00 ps -ef

******************************************
SEARCH OF OUTPUT FILE (when problem does not occur)
******************************************
tmp>grep pts\/0 junk
edat 17852 28470 1 15:36:44 pts/0 0:00 -ksh
edat 50054 17852 1 10:20:01 pts/0 0:00 /usr/bin/sh checkPS2.sh
edat 50400 50054 0 10:20:01 pts/0 0:00 awk {print $1}
edat 52060 50400 0 10:20:01 pts/0 0:00 tee junk
edat 48634 50400 0 10:20:01 pts/0 0:00 grep checkPS2.sh
edat 48354 50400 4 10:20:01 pts/0 0:00 ps -ef

We updated the libc.a library to match that of the other servers but that did not resolve the problem.

Am I simply facing a race condition here or is there more than meets the eye?

Thanks in advance.

Last edited by johnnieb; 10-19-2005 at 11:26 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

The "PS" command was displaying*terminals named as "SYSCON"

Hi, When typing the command ps -fe.the system is showing a process called SYSCON:confused:.... I am not sure what process is that.I hava a script that kills all command staring with 'sys' but i don't want to kill syscon:( since i think it is some system process:confused: .Please help me to find... (1 Reply)
Discussion started by: kiranjose85
1 Replies

2. Shell Programming and Scripting

"UNIX Shells By Example" CD Files

hello All, I just purchased a used copy of "UNIX Shells by Example" by Ellie Quigley. The CD is not in the back. I googled the world but the files dont seem to be available for download anywhere. Does anyone out there have them. It would be much appreciated if someone can email them to me. ... (1 Reply)
Discussion started by: tag0519
1 Replies

3. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

4. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

5. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

6. UNIX for Dummies Questions & Answers

Explanation of "total" field in "ls -l" command output

When I do a listing in one particular directory (ls -al) I get: total 43456 drwxrwxrwx 2 root root 4096 drwxrwxrwx 3 root root 4096 -rwxrwxr-x 1 nobody nobody 3701594 -rwxrwxr-x 1 nobody nobody 3108510 -rwxrwxr-x 1 nobody nobody 3070580 -rwxrwxr-x 1 nobody nobody 3099733 -rwxrwxr-x 1... (1 Reply)
Discussion started by: proactiveaditya
1 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
PTS_SOURCE(1)						       AFS Command Reference						     PTS_SOURCE(1)

NAME
pts_source - Read pts commands from a file SYNOPSIS
pts source [-file] <file name> [-cell] <cell name> [-noauth] [-localauth] [-force] pts so [-f] <file name> [-c] <cell name> [-n] [-l] [-f] DESCRIPTION
The pts source runs commands from a file as if they were typed in pts interactive mode. The command can be run from the command line or interactively. CAUTIONS
Prior to OpenAFS 1.4.5 and OpenAFS 1.5.23, the pts source command was only available on Unix or Linux and when OpenAFS was compiled with the supergroups option (disabled by default). As of OpenAFS 1.4.5 and 1.5.23, it is always available. OPTIONS
pts source takes the following options: -cell <cell name> Names the cell in which to run the command. For more details, see pts(1). -force Enables the command to continue executing as far as possible when errors or other problems occur, rather than halting execution at the first error. -help Prints the online help for this command. All other valid options are ignored. -localauth Constructs a server ticket using a key from the local /etc/openafs/server/KeyFile file. Do not combine this flag with the -cell or -noauth options. For more details, see pts(1). -noauth Assigns the unprivileged identity anonymous to the issuer. For more details, see pts(1). OUTPUT
This command shows the output of each command in the file as if it were run normally. EXAMPLES
Here is an example of using pts source in a pts interactive session: % echo examine admin > /tmp/commands.txt % pts interactive pts> source /tmp/commands.txt Name: admin, id: 1, owner: system:administrators, creator: anonymous, membership: 2, flags: S----, group quota: 20. pts> quit % SEE ALSO
pts(1), pts_interactive(1), pts_quit(1), pts_sleep(1) COPYRIGHT
Copyright 2007 Jason Edgecombe <jason@rampaginggeek.com> This documentation is covered by the BSD License as written in the doc/LICENSE file. This man page was written by Jason Edgecombe for OpenAFS. OpenAFS 2014-04-08 PTS_SOURCE(1)
All times are GMT -4. The time now is 12:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy