Sponsored Content
Top Forums Shell Programming and Scripting Why does the 'pid' keep changing every time? Post 302383639 by methyl on Wednesday 30th of December 2009 11:34:51 AM
Old 12-30-2009
Belt and braces approach in case there is more than one hit.

Code:
ps -ef|grep 'process_name'|grep -v "grep"|awk '{print $2}'|while read PID
do
      echo "PID=${PID}"
done


Ps. Scrutinizer is right, you were getting PID of the awk.

The answer to your supplementary is:
Code:
ps -fp${PID}

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to MV without changing Time Stamp

Hi, I need to move the set of files, and it should be same time stamp as previous. How to do this? (3 Replies)
Discussion started by: redlotus72
3 Replies

2. Shell Programming and Scripting

changing modified time

How to change the modified time of a file to any specified time. ls -ltr drwxr-xr-x 2 pipe pipe 4096 Jun 10 10:33 coredump_06062008 ---------------------------------------------------------------------- here file coredump_06062008 last modified time is Jun 10 10:33 and i... (1 Reply)
Discussion started by: ali560045
1 Replies

3. Shell Programming and Scripting

Changing the output in own time display's.

Hi all, I've written a script which collects some information and sendsout a mail.. (code pasted below) ssh -l ora${sid} ${primaryhost} "tail -50 /oracle/$ORACLE_SID/newbackup/END_BACKUP.log" |grep 'insert' |tail -1| awk '{print $7}' >> ${RESULTFILE} Output would look like this:... (1 Reply)
Discussion started by: suri.tyson
1 Replies

4. AIX

changing server time

Hi all, we have IBM- AIX 5.2 operating system on that we have our oracle production database and there is daily crontab script for backup. my boss told me to change the server time.if i change the server time by root user does it give problem to any application or script which are... (2 Replies)
Discussion started by: younusdba
2 Replies

5. HP-UX

Changing system time in HP-UX using perl

Hi All, I would like to change system time for my testing purposes. All I need is to change the system time forward/backward in seconds. I am providing the perl code that I am using to change system time on all platforms. --------- use strict; use English; my $sec; my $mday; my... (2 Replies)
Discussion started by: xyz3245
2 Replies

6. AIX

changing the time zone in aix

hi may aix version is 6100-06-03-1048 when i give date command it shows the time zone as root@cbspsgui01 #date Fri Sep 16 08:43:42 Africa/Johannesburg 2011 I want to change the time zone to GMT +02:00: After i change the time zone it should show something like the one below when i type... (2 Replies)
Discussion started by: newtoaixos
2 Replies

7. UNIX for Dummies Questions & Answers

Start Time and period of a PID

Hi, Below is my OS details. uname -an SunOS mymachine 5.10 Generic_144488-07 sun4v sparc SUNW,SPARC-Enterprise-T5220 I need to know when was my Apache server last started. Whats is the best and most reliable way to find out not just for Apache but for any PID per say? I am... (16 Replies)
Discussion started by: mohtashims
16 Replies

8. Shell Programming and Scripting

Changing time-stamp with sed

Hi ! I try to change a time-stamp hh:mm:ss allways to full ten-minutes. example: 12:51:03 to 12:50:03 sed 's/::/:{0-5}0:/g' file.txt but it will not work propperly, because the minute-decade will be replaced with the bracket-term {0-5}. Can someone please give me a hint? Thanks in... (6 Replies)
Discussion started by: IMPe
6 Replies

9. Red Hat

Touch - changing date and time

Hi, I am facing a problem with the command - TOUCH on Linux. See the example below: File on Linux: rw-rw-r-- user1 user1 Jan 01 09:00 test.txt The file - test.txt was created by the user - user1. Now, I want to change the date and time, but using other user - user2 The user2... (12 Replies)
Discussion started by: brjohnsmith
12 Replies

10. Shell Programming and Scripting

Kill nohup process with changing PID

Hi there! I have a tricky problem concerning a nohup process: I started a python2.7 script which loops over a function. At the end it restarts the function. Due to a mistake I'm now having a never ending nohup process that I have to kill. I started the program execution with: >>nohup... (4 Replies)
Discussion started by: Lydia
4 Replies
ptree(1)						      General Commands Manual							  ptree(1)

NAME
ptree - prints the process tree hierarchy SYNOPSIS
[pid1|username1 [pid2|username2]...] DESCRIPTION
prints the process tree of all processes that match the specified arguments. While printing the tree, the child processes are indented to the right from their respective parent processes. Options Prints the tree starting from the children of (usually pid 0). The default is to print the tree starting from the children of (pid 1). Operands pid Print the process tree for the process ID number specified by pid. username Print the process tree for all the processes from the user specified by username. Note that only username (and not user ID) can be specified for this instance. If no operands are specified, then prints the process tree of all processes starting from the children of or (if is specified). EXTERNAL INFLUENCES
Environment Variables If is not specified or is null, it defaults to (see lang(5)). EXAMPLES
Print the process tree for pid 100 and for all processes owned by WARNINGS
Process information can change while is running; the tree displayed by is only a snapshot in time. Some data printed for defunct processes is irrelevant. Users of must not rely on the exact field widths and spacing of its output, as these will vary depending on the system and the release of HP-UX. SEE ALSO
pgrep(1), pkill(1), ps(1), fork(2). ptree(1)
All times are GMT -4. The time now is 10:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy