Sponsored Content
Top Forums Shell Programming and Scripting Websphere Running processes script Post 302897753 by KingaKoopa on Wednesday 16th of April 2014 01:22:08 PM
Old 04-16-2014
Corona688,
Im on linux redhat

Im looking for something like,

Dmgr-1234
BPM.AppSvr-2467
BPM.WebSvr-1212
BPM.Messaging-3214
nodeagent(Node1)-9875
nodeagent(Node2)-34323

Everything before the hyphen (-) like dmgr BPM.* nodeagent(Node1/2) is in the process its just that i suck this this whole thing.

---------- Post updated at 05:15 PM ---------- Previous update was at 05:10 PM ----------

pilnet 101 ,
I appreciate you helping me out.I really do.
As i said , i struggle a lot with this kind of stuff....

---------- Post updated 04-16-14 at 11:12 AM ---------- Previous update was 04-15-14 at 05:15 PM ----------

Quote:
Originally Posted by pilnet101
The issue is that you are echoing the value of $p after you assign the $BPMPROCID variable. The value of $p is hard coded in $PROCS list. What you would need to do is create a new variable in the same way you created $BPMPROCID to dynamically pick up the actually process name.

I am not sure where the process name (i.e. Nodeagent) gets outputted on the screen, but say if it is the last word on the line when performing 'ps aux' , the below amendments (assigning a PNAME variable and printing that instead of $p) should work for you. Hope this helps.

Code:
#!/bin/bash
PROCS="DMgr BPM.AppTarget BPM.Support BPM.WebApp BPM.Messaging nodeagent App.Messaging "
for p in $PROCS
do
PROCEXIST=$(ps aux | grep $p | grep -v grep)

if [ "$PROCEXIST" != "" ]; then
BPMPROCID=$(ps aux | grep $p | grep -v grep | awk '{print $2}')
PNAME=$(ps aux | grep $p | grep -v grep | awk '{print $NF}')
echo "$PNAME:PID $BPMPROCID"
fi
done

Btw obviously Corona is right, there are of course more effective/efficient ways of doing this, I'm just trying to help to benefit your understanding at the very least.





tried that and i got this "exact" output


TheNameOfTheCell:PID 22200
BPM.Support:PID 21675
BPM.WebApp:PID 21925
nodeagent
nodeagent:PID 13530
13913

---------- Post updated at 12:22 PM ---------- Previous update was at 11:12 AM ----------

seems like its still messing up on the nodeagent part
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

script to kill rsh processes running for more than 10 minutes

Hi Friends, I need to write a script to kill some processes running for more than 10 minutes. Can I get some pointers on that. Thanks for ur help in Advance. Thanks&Regards, Amit (1 Reply)
Discussion started by: amitsayshii
1 Replies

2. Shell Programming and Scripting

script to kill rsh processes running for more than 10 minutes

Hi Friends, I need to write a script to kill some processes running for more than 10 minutes. Can I get some pointers on that. Thanks for ur help in Advance. Thanks&Regards, Amit (1 Reply)
Discussion started by: amitsayshii
1 Replies

3. UNIX for Dummies Questions & Answers

Script to kill rsh processes running for more than 10 mins

Hi Friends, I need to write a script to kill some processes running for more than 10 minutes. Can I get some pointers on that. Thanks for ur help in Advance. Thanks&Regards, Amit (3 Replies)
Discussion started by: amitsayshii
3 Replies

4. Shell Programming and Scripting

Script to check running processes on remote server.

Hi, I am trying to write a script, which queries a db to get the names of processes, stores it in a file and then checks if that process is running on a remote server. However I am not getting it right, could anyone help me out. #!/bin/sh echo "select Address from Device where Cust =... (5 Replies)
Discussion started by: amitsayshii
5 Replies

5. Shell Programming and Scripting

Script for long running processes....

I searched the forums but didn't see anything related to what I'm looking for. I need a script that would give me a listing of jobs running longer than, for example, 12 hours or so. Thanks in advance for your assistance!! (2 Replies)
Discussion started by: CyberOptiq
2 Replies

6. Shell Programming and Scripting

Need help with running processes script

I'm doing a script with the Shell. I need that it only show the number of running processes. Ex: echo "There are `command` running processes" Thnx! Pd: Sorry the idiom. I'm spanish. (2 Replies)
Discussion started by: Ikebana
2 Replies

7. Shell Programming and Scripting

Need help with running processes script

I'm doing a script with the Shell. I need that it only show the number of running processes. Ex: echo "There are `command` running processes" Thnx! Pd: Sorry the idiom. I'm spanish. (5 Replies)
Discussion started by: Ikebana
5 Replies

8. Shell Programming and Scripting

A script that kills previous instances of itself upon running not killing child processes

I'm likely going to explain this clumsily, so apologies in advance: I have the following script: #!/bin/bash pidPrefix="logGen" checkPrime () { if /sbin/ifconfig eth0:0|/bin/grep -wq inet;then isPrime=1;else isPrime=0;fi } killScript () { /usr/bin/find /var/run -name... (4 Replies)
Discussion started by: DeCoTwc
4 Replies

9. Solaris

Running processes on GZ/LZ

Hi guys just a question is it normal to see running process on a non-global zone in the global zone... processes such as cron. (3 Replies)
Discussion started by: batas
3 Replies

10. Linux

Running processes

Hi guys is it normal to have 5-10 cron/syslog processes running... in my case i got 10 cron process running. (4 Replies)
Discussion started by: batas
4 Replies
SYSTEMD-RC-LOCAL-GENERATOR(8)				    systemd-rc-local-generator				     SYSTEMD-RC-LOCAL-GENERATOR(8)

NAME
systemd-rc-local-generator - Compatibility generator for starting /etc/rc.local and /usr/sbin/halt.local during boot and shutdown SYNOPSIS
/lib/systemd/system-generators/systemd-rc-local-generator DESCRIPTION
systemd-rc-local-generator is a generator that checks whether /etc/rc.local exists and is executable, and if it is pulls the rc-local.service unit into the boot process. This unit is responsible for running this script during late boot. Note that the script will be run with slightly different semantics than the original System V version, which was run "last" in the boot process, which is a concept that does not translate to systemd. The script is run after network.target, but in parallel with most other regular system services. systemd-rc-local-generator also checks whether /usr/sbin/halt.local exists and is executable, and if it is pulls the halt-local.service unit into the shutdown process. This unit is responsible for running this script during later shutdown. Support for both /etc/rc.local and /usr/sbin/halt.local is provided for compatibility with specific System V systems only. However, it is strongly recommended to avoid making use of these scripts today, and instead provide proper unit files with appropriate dependencies for any scripts to run during the boot or shutdown processes. systemd-rc-local-generator implements systemd.generator(7). SEE ALSO
systemd(1), systemctl(1) systemd 237 SYSTEMD-RC-LOCAL-GENERATOR(8)
All times are GMT -4. The time now is 02:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy