Sponsored Content
Top Forums Shell Programming and Scripting Tracking process via ps command Post 302853411 by ahamed101 on Saturday 14th of September 2013 05:41:35 AM
Old 09-14-2013
Yes, that should do.
And btw you can check the output of pgrep directly rather than checking the exit status.

--ahamed
This User Gave Thanks to ahamed101 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

process command

I'm looking for a specific command to extract the libraries linked to a specific process. Would someone get an idea ?? (2 Replies)
Discussion started by: tonoche
2 Replies

2. UNIX for Advanced & Expert Users

Command Tracking

Hi, OS: Solaris9, SPARC Is there any way I can track the commands run by users from the shell prompt? Example: Somebody is deleting files from the system. Who it is is a mystery. That person obviously does not use bash prompt so there is no history. Is there anyway I can find out who... (5 Replies)
Discussion started by: mahatma
5 Replies

3. Shell Programming and Scripting

Process ID of Command

I need a way to get the Process ID of the last command I executed in a script. Not the last background process but the last command. For example, suppose I am executing a binary inside a script like so. binary.program argument1 argument2 If this binary program runs fast, is there a... (4 Replies)
Discussion started by: scotbuff
4 Replies

4. UNIX for Advanced & Expert Users

Tracking user

dear all, I'm facing problem that is i have noticed from few days back that some body is deleting and making changes in the file from developement server where i'm working(in unix) so i want to track that who is using the server, what performancr they are doing and each every thing which r... (5 Replies)
Discussion started by: panknil
5 Replies

5. UNIX for Advanced & Expert Users

Tracking down the problem

Is there a way to track down what process is sending to a certain port? I have some thing pounding the network with requests to a multicast IP that doesn't exist. I have shut down all comms related processes and yet it is still there. Need a way to track the port or IP back to the process. Thanks... (3 Replies)
Discussion started by: mattmanuel
3 Replies

6. IP Networking

Routing by connection tracking

Hello, I have switch port, that allows only a single MAC/IP connected to it. - But, I would like to connect two hosts, without any additional private network. (No NAT.) Therefore the plan is adding a linux router doing proxy-arp with three interfaces, one for host1, one for host2 and one... (2 Replies)
Discussion started by: michas
2 Replies

7. Red Hat

Tracking Process to a particular

I've tried to see what I can find on my own but I'm coming up with goose eggs. Basically I was wondering if there was a way of querying the scheduler (or something similar) to track a process back to a particular CPU it's executing on at the time of the command. ps has a "cpu" output option but... (1 Reply)
Discussion started by: thmnetwork
1 Replies

8. Shell Programming and Scripting

Tracking users through history command

Hi folks, I have the basic query that there are 3 unix boxes having their individual access now in my team there are 4 members who are using the same credentials to access those 3 boxes through putty ssh from their windows desktop , now if i want to check which 4 members have executed the... (1 Reply)
Discussion started by: punpun66
1 Replies

9. UNIX for Advanced & Expert Users

Issue with tracking successful completion of Child process running in background

Hello All, I am using Linux. I have two scripts: inner_script.ksh main_wrapper_calling_inner.ksh Below is the code snippet of the main_wrapper_calling_inner.ksh: #!/bin/ksh ppids=() ---> Main array for process ids. fppids=() ---> array to capture failed process ids. pcnt=0 --->... (5 Replies)
Discussion started by: dmukherjee
5 Replies

10. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies
PGREP(1)                                                           User Commands                                                          PGREP(1)

NAME
pgrep, pkill - look up or signal processes based on name and other attributes SYNOPSIS
pgrep [options] pattern pkill [options] pattern DESCRIPTION
pgrep looks through the currently running processes and lists the process IDs which match the selection criteria to stdout. All the crite- ria have to match. For example, $ pgrep -u root sshd will only list the processes called sshd AND owned by root. On the other hand, $ pgrep -u root,daemon will list the processes owned by root OR daemon. pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout. OPTIONS
-signal --signal signal Defines the signal to send to each matched process. Either the numeric or the symbolic signal name can be used. (pkill only.) -c, --count Suppress normal output; instead print a count of matching processes. When count does not match anything, e.g. returns zero, the command will return non-zero value. -d, --delimiter delimiter Sets the string used to delimit each process ID in the output (by default a newline). (pgrep only.) -f, --full The pattern is normally only matched against the process name. When -f is set, the full command line is used. -g, --pgroup pgrp,... Only match processes in the process group IDs listed. Process group 0 is translated into pgrep's or pkill's own process group. -G, --group gid,... Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used. -i, --ignore-case Match processes case-insensitively. -l, --list-name List the process name as well as the process ID. (pgrep only.) -a, --list-full List the full command line as well as the process ID. (pgrep only.) -n, --newest Select only the newest (most recently started) of the matching processes. -o, --oldest Select only the oldest (least recently started) of the matching processes. -P, --parent ppid,... Only match processes whose parent process ID is listed. -s, --session sid,... Only match processes whose process session ID is listed. Session ID 0 is translated into pgrep's or pkill's own session ID. -t, --terminal term,... Only match processes whose controlling terminal is listed. The terminal name should be specified without the "/dev/" prefix. -u, --euid euid,... Only match processes whose effective user ID is listed. Either the numerical or symbolical value may be used. -U, --uid uid,... Only match processes whose real user ID is listed. Either the numerical or symbolical value may be used. -v, --inverse Negates the matching. This option is usually used in pgrep's context. In pkill's context the short option is disabled to avoid accidental usage of the option. -w, --lightweight Shows all thread ids instead of pids in pgrep's context. In pkill's context this option is disabled. -x, --exact Only match processes whose names (or command line if -f is specified) exactly match the pattern. -F, --pidfile file Read PID's from file. This option is perhaps more useful for pkill than pgrep. -L, --logpidfile Fail if pidfile (see -F) not locked. --ns pid Match processes that belong to the same namespaces. Required to run as root to match processes from other users. See --nslist for how to limit which namespaces to match. --nslist name,... Match only the provided namespaces. Available namespaces: ipc, mnt, net, pid, user,uts. -V, --version Display version information and exit. -h, --help Display help and exit. OPERANDS
pattern Specifies an Extended Regular Expression for matching against the process names or command lines. EXAMPLES
Example 1: Find the process ID of the named daemon: $ pgrep -u root named Example 2: Make syslog reread its configuration file: $ pkill -HUP syslogd Example 3: Give detailed information on all xterm processes: $ ps -fp $(pgrep -d, -x xterm) Example 4: Make all netscape processes run nicer: $ renice +4 $(pgrep netscape) EXIT STATUS
0 One or more processes matched the criteria. 1 No processes matched. 2 Syntax error in the command line. 3 Fatal error: out of memory etc. NOTES
The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat. Use the -f option to match against the complete command line, /proc/pid/cmdline. The running pgrep or pkill process will never report itself as a match. BUGS
The options -n and -o and -v can not be combined. Let me know if you need to do this. Defunct processes are reported. SEE ALSO
ps(1), regex(7), signal(7), killall(1), skill(1), kill(1), kill(2) AUTHOR
Kjetil Torgrim Homme <kjetilho@ifi.uio.no> REPORTING BUGS
Please send bug reports to <procps@freelists.org> procps-ng March 2015 PGREP(1)
All times are GMT -4. The time now is 08:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy