db_sid_pro="ora_smon_$db_sid"
if pgrep -u oracle -x "$db_sid_pro" >/dev/null
then
tag="true"
msg="$db_sid database instance is running"
echo "$db_sid_pro database process is running"
else
...
fi
The shell script uses the exit status from pgrep and throws its result away. (Alternatively you could capture the result in a variable and then test it for having a value: pid=`pgrep ...`; if test -n "$pid")
The -u oracle and -x options make the match even more precise.
See man pgrep.
Hi,
Am supposed to use message queues to send and receive messages between the processes. when i was working on that i realised that the message qid and the message queue related data should be maintained in a shared memory so that it can be accessed by all the processes. Could anybody refer... (10 Replies)
I am trying to write a script that will help me put a file into excel with little manipulation. Below is a sample of the file im using.
Group1:*:gid1:user,user
Group2:*:gid2:user,user
Group3:*:gid3:user,user,user,user,user,user,user
Group4:*:gid4:user,user
I marked in red the part that is... (1 Reply)
Hello all, I have been asked to exercise my shell scripting and it has been 10 plus years since I used to do it so I can not remember hardly anything and ask for your help.
What I need to do is copy a line out of a file that can be 10 to 100 characters long, I then need to parse this line into... (3 Replies)
I have a file with data records separated by multiple equals signs, as below.
==========
RECORD 1
==========
RECORD 2
DATA LINE
==========
RECORD 3
==========
RECORD 4
DATA LINE
==========
RECORD 5
DATA LINE
==========
I need to filter out all data from this file where the... (2 Replies)
i have to remove the commented (/* . . . .*/) part which starts in one line and ends in other.help me with generic code because i have 1000 to 10k lines code which i have to remove.
data one;
set work.temp;
input name age;
infile filename;
/* dfsdf
dsfs
sdfdf
dsdd
sdfsf
sdfsf
sfs... (4 Replies)
It looks like if matching and deleting the last line confuses 'sed' so it does not recognize '$' address. Consider:
sed -e '/^3/d' -e '$ a text'
supposed to delete a line starting with '3' and then append 'text' after the last line of input. But, if it is the last line of input which starts... (2 Replies)
Hello,
Currently, I am reading few queries from the below .sql file
--SOURCE TABLE NAME
--SOURCE QUERY
SEL COL1, COL2, COL3, COL4,
COL5, COL6, COL7 WHERE COL5 = '2015-11-04 16:24:00.000000' FROM SOURCE TABLE;
--TARGET TABLE NAME
--TARGET QUERY
SEL COLUMN1, COLUMN2, COLUMN3, COLUMN4,... (4 Replies)
Hi there,
I'm trying to create a script that will accept multiple inputs by copying and pasting the strings from a notepad, hit Enter key and output the string to a text file.I'm thinking of using the read command however it will just simply get the first line.
Apologies but got no idea how... (7 Replies)
Hi,
Can anyone help me for merge the following multi-line log which beginning with a " and line ending with ": into one line.
*****Original Log*****
087;2008-12-06;084403;"mc;;SYHLR6AP1D\LNZW;AD-703;1;12475;SYHLR6AP1B;1.1.1.1;0000000062;HGPDI:MSISDN=12345678,APNID=1,EQOSID=365;... (3 Replies)
Discussion started by: rajeshlinux2010
3 Replies
LEARN ABOUT DEBIAN
pgrep
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 matches the selection criteria to stdout. All the cri-
teria 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. (pgrep only.)
-d, --delimeter 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.
-l, --list-name
List the process name 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 usually used in pgrep context. In pkill context the short option is disabled to avoid accidental
usage of the option.
-x, --exact
Only match processes whose name (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.
-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)STANDARDS
pkill and pgrep were introduced in Sun's Solaris 7. This implementation is fully compatible.
AUTHOR
Kjetil Torgrim Homme <kjetilho@ifi.uio.no>
REPORTING BUGS
Please send bug reports to <procps@freelists.org>
procps-ng September 2011 PGREP(1)