Comparing a text file's entries with ps -ef output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comparing a text file's entries with ps -ef output
# 1  
Old 03-27-2012
Comparing a text file's entries with ps -ef output

Shell : Korn
os : AIX

This is the ps output looking for a process called pmon. pmon runs with various 'service' names which is appended with an underscore as shown below.

For example a pmon process for the service hexjkm will be named ora_pmon_hexjkm


HTML Code:
$ ps -ef | grep pmon

  oracle  4128852        1   0   Nov 10      - 14:59 ora_pmon_hexjkm 
  oracle  4849792        1   0   Nov 10      - 15:04 ora_pmon_yevnes 
  oracle  7274610        1   0   Nov 10      - 20:50 ora_pmon_ceespr 
  oracle  7471232        1   0   Nov 10      - 23:25 ora_pmon_niclkn 
  oracle  8913076        1   0   Nov 10      - 19:12 ora_pmon_lmstpu 
  oracle 11403284        1   0   Nov 10      - 19:31 ora_pmon_cectpr 
  oracle 13107282        1   0   Nov 10      - 14:47 ora_pmon_cesass 
  oracle 15270050        1   0   Nov 10      - 19:30 ora_pmon_ukcocs 
  oracle 16318666        1   0   Nov 10      - 27:05 ora_pmon_fgcocs 
  oracle 16580818        1   0   Nov 10      - 14:53 ora_pmon_ceesbr 
  oracle 16646356        1   0   Nov 10      - 19:42 ora_pmon_plcocs 
  oracle 16711894        1   0   Nov 10      - 16:05 ora_pmon_ceboas 
  oracle 21364870        1   0   Nov 10      - 24:17 ora_pmon_cecocr 
  oracle 22741182        1   0   Nov 10      - 24:52 ora_pmon_ceclcr 
  oracle 24903694        1   0   Feb 16      -  4:56 ora_pmon_emcops 
  oracle 29032624        1   0   Feb 16      -  4:42 ora_pmon_emcopr 
  oracle 43122910        1   0   Mar 23      -  0:29 ora_pmon_cecmcr 
  oracle  6947270        1   0   Nov 10      - 17:45 ora_pmon_emcwar 
  oracle  7078360        1   0   Nov 10      - 18:43 ora_pmon_emcwas 
  oracle  7602490        1   0   Jan 06      - 13:37 ora_pmon_cetcnc 
  oracle  7930212        1   0   Nov 10      - 17:44 ora_pmon_ceurfs 
  oracle 38666612        1   0   Feb 21      -  8:55 ora_pmon_cecmcs 
  oracle 45809970        1   0   Mar 08      -  4:15 ora_pmon_wtcocs 
  oracle 63701382        1   0   Feb 24      -  7:38 ora_pmon_facuyr 
  oracle 16056858        1   0   Feb 15      -  5:08 ora_pmon_cecpcs 
  oracle 21824140        1   0   Mar 19      -  0:51 ora_pmon_lebtcs 
  oracle 52232842        1   0   Mar 08      -  2:41 ora_pmon_uedopl
Below is text file named mustRun.lst, which contains entries of service names.

HTML Code:
$ cat mustRun.lst

yevnes
ceboas
ukcocs
plcocs
fgcocs
cecocr
cesass
ceurfs
cecpcs
ceclcr
ceesbr
cectpr
cecmcr
cecmcs
ceespr
niclkn
hexjkm
lebtcs
cetcnc
facuyr
lmstpu
emcwar
emcopr
emcwas
emcops
uedopl
wtcocs
Every morning I need to check a set of mandatory processes (listed in mustRun.lst) and make sure that it is running (ie. present in ps output)

So, I need to find the service names which are present in mustRun.lst file but absent from ps -ef output. Is there any way to do this using scripting ?
# 2  
Old 03-27-2012
try something like below
Code:
ps -ef | grep pmon > psOracle.dat
awk  'FILENAME=="psOracle.dat"{A[$1]=$1} FILENAME=="mustRun.lst"{if(A[$1]!=$1){print}}' psOracle.dat mustRun.lst

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing 2 text files & downloading a file if the last lines are different

Hello I'm having a little difficulty in writing a shell script for a few simple tasks. First I have two files "file1.txt" and "file2.txt" and I want to read and compare the last line of each file. The files look like this. File1.txt File2.txt After comparing the two lines I would... (2 Replies)
Discussion started by: RustikGaming
2 Replies

2. Shell Programming and Scripting

Script for Comparing directories and file from a text file

Hello all, I need to write a script which has following requirement: Need to read the filenames from text file and then search for the above read files in the required directory and if match found backup them in a backup folder. And also need to compare and verify whether the files in the... (7 Replies)
Discussion started by: saurau
7 Replies

3. Shell Programming and Scripting

Comparing text in 2 files and output difference in another file.

I have 2 files of almost same text apart from 2,3 ending lines. Now I want to get that difference in another file. e.g file1.txt is Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_livecd-lv_root 18G 2.4G 15G 14% / tmpfs 504M ... (12 Replies)
Discussion started by: kashif.live
12 Replies

4. Shell Programming and Scripting

Comparing file with Sql output.

Hi Guys, I need to compare the sql output with a column present in a file. I am able to read the column from the file and stored in a variable. Can somebody help how to store output of the below query to a variable. The database is Oracle. Select count(*) from tableName; ... (2 Replies)
Discussion started by: mac4rfree
2 Replies

5. UNIX Desktop Questions & Answers

COMPARING COLUMNS IN A TEXT FILE

Hi, Good day. I currently have this data called database.txt and I would like to check if there are no similar values (all unique) on an entire row considering the whole column data is unique. the data is as follows cL1 cL2 cL3 cL4 a12 c13 b13 c15 b11 a15 c19 b11 c15 c17 b13 f14 with... (1 Reply)
Discussion started by: whitecross
1 Replies

6. UNIX for Dummies Questions & Answers

Comparing a number in a text file with a specific value

My project is to get a temperature reading from a refridgerator every 2 minutes and check to see if the door has been left open. I don't yet have the mastery of Linux, being a complete noob, but I reckon I need a text file with the latest temperature reading in it. This I've managed to do by... (2 Replies)
Discussion started by: Fitch
2 Replies

7. Shell Programming and Scripting

Comparing and Formatting the text file

hi, I need a script which can format the below text file which contains comments file1.txt -------- //START //Name: some value //Date: //Changes:............. //..................... //END //START //Date: //Name: some value //Changes:............. //..................... (3 Replies)
Discussion started by: flamingo_l
3 Replies

8. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

9. Shell Programming and Scripting

Reading text file and comparing the dates in Kshell

I have a text file in which holidays are listed as YYYYMMDD. Here is the sample data of the file. 20090911 20090912 20090913 I need to read this file and see if the current day is listed in this text file. If today and any of the rows in my text file match, I need to do further... (2 Replies)
Discussion started by: Pramodini Rode
2 Replies

10. UNIX for Dummies Questions & Answers

Comparing file names to text document

Hi All, I'm really new to Unix scripts and commands but i think i'm eventually getting the hang of some of it. I have a task which is to create some kind of script which compares the file names in a directory, with the associated file name in a .txt file. We send out some data and Unix has a... (1 Reply)
Discussion started by: gman
1 Replies
Login or Register to Ask a Question