LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-05-2016, 01:44 AM   #1
asteroid4u
Member
 
Registered: Jun 2015
Posts: 58

Rep: Reputation: Disabled
find Patient process


Hi Guys,

I want to find my simv process is started from /opt/sge/default/something process or not. I can use below command show process id and parent process ID but in few cases simv is not directly started from /opt/sge/default/something

To find simv process i used:
ps xao user,pid,ppid,comm | grep 'simv'
regress 7977 7968 simv
regress 27307 27298 simv--> this process is started from /opt/sge/default/something
1363 29025 29018 simv--> this also started from /opt/sge/default/something but is parent process is differnt

Below the example
[root@cin230 ~]# ps 27298
PID TTY STAT TIME COMMAND
27298 ? SNs 0:00 bash /opt/sge/default/spool/cin230/job_scripts/3022732
[root@cin230 ~]# ps 29018
PID TTY STAT TIME COMMAND
29018 ? S 0:00 /bin/bash /dv6//home/saravanakumars/T6_tree/verif/top/sys_Ing/run.local.ASIC.ntb/tls/tls_in
[root@cin230 ~]# ps -p "29018" -o ppid=
29008
[root@cin230 ~]# ps 29008
PID TTY STAT TIME COMMAND
29008 ? S 0:00 tcsh -c /dv6//home/saravanakumars/T6_tree/verif/top/sys_Ing/run.local.ASIC.ntb/tls/tls_ingr
[root@cin230 ~]# ps -p "29008" -o ppid=
29001
[root@cin230 ~]# ps 29001
PID TTY STAT TIME COMMAND
29001 ? Ss 0:00 /opt/sge/utilbin/lx-amd64/qrsh_starter /opt/sge/default/spool/cin230/active_jobs/3031200.1

I want to find whether whether simv process is spawned from /opt/sge/default/something or not.

Thanks in advance.
 
Old 01-05-2016, 02:18 AM   #2
fmattheus
Member
 
Registered: Nov 2015
Posts: 104

Rep: Reputation: 38
One option would be
Code:
ps -ef | egrep '/opt/sge/default/.*simv'
 
Old 01-05-2016, 02:47 AM   #3
asteroid4u
Member
 
Registered: Jun 2015
Posts: 58

Original Poster
Rep: Reputation: Disabled
Hi Fmattheus,

Thanks for reply but your command is not working

Currenty running 3 simv process
[root@cin230 ~]# ps xao user,pid,ppid,comm | grep 'simv'
regress 27307 27298 simv
1363 29025 29018 simv
regress 29560 29551 simv

when i used the your command its giving below command

[root@cin230 ~]# ps -ef | egrep '/opt/sge/default/.*simv'
root 20551 6242 0 00:45 pts/1 00:00:00 egrep /opt/sge/default/.*simv

Any help
 
Old 01-05-2016, 03:13 AM   #4
fmattheus
Member
 
Registered: Nov 2015
Posts: 104

Rep: Reputation: 38
Ok, then show us the output of
Code:
ps -ef
 
Old 01-05-2016, 03:15 AM   #5
asteroid4u
Member
 
Registered: Jun 2015
Posts: 58

Original Poster
Rep: Reputation: Disabled
[root@cin230 ~]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 2015 ? 00:00:16 init [5]
root 2 1 0 2015 ? 00:00:59 [migration/0]
root 3 1 0 2015 ? 00:00:29 [ksoftirqd/0]
root 4 1 0 2015 ? 00:00:00 [watchdog/0]
root 5 1 0 2015 ? 00:00:26 [migration/1]
root 6 1 0 2015 ? 00:00:14 [ksoftirqd/1]
root 7 1 0 2015 ? 00:00:00 [watchdog/1]
root 8 1 0 2015 ? 00:00:32 [migration/2]
root 9 1 0 2015 ? 00:00:54 [ksoftirqd/2]
root 10 1 0 2015 ? 00:00:00 [watchdog/2]
root 11 1 0 2015 ? 00:00:23 [migration/3]
root 12 1 0 2015 ? 00:00:10 [ksoftirqd/3]
root 13 1 0 2015 ? 00:00:00 [watchdog/3]
root 14 1 0 2015 ? 00:00:25 [migration/4]
root 15 1 0 2015 ? 00:00:52 [ksoftirqd/4]
root 16 1 0 2015 ? 00:00:00 [watchdog/4]
root 17 1 0 2015 ? 00:00:28 [migration/5]
root 18 1 0 2015 ? 00:00:12 [ksoftirqd/5]
root 19 1 0 2015 ? 00:00:00 [watchdog/5]
root 20 1 0 2015 ? 00:00:26 [migration/6]
root 21 1 0 2015 ? 00:01:02 [ksoftirqd/6]
root 22 1 0 2015 ? 00:00:00 [watchdog/6]
root 23 1 0 2015 ? 00:00:29 [migration/7]
root 24 1 0 2015 ? 00:00:10 [ksoftirqd/7]
root 25 1 0 2015 ? 00:00:00 [watchdog/7]
root 26 1 0 2015 ? 00:00:12 [migration/8]
root 27 1 0 2015 ? 00:00:01 [ksoftirqd/8]
root 28 1 0 2015 ? 00:00:00 [watchdog/8]
root 29 1 0 2015 ? 00:00:11 [migration/9]
root 30 1 0 2015 ? 00:00:00 [ksoftirqd/9]
root 31 1 0 2015 ? 00:00:00 [watchdog/9]
root 32 1 0 2015 ? 00:00:08 [migration/10]
root 33 1 0 2015 ? 00:00:00 [ksoftirqd/10]
root 34 1 0 2015 ? 00:00:00 [watchdog/10]
root 35 1 0 2015 ? 00:00:08 [migration/11]
root 36 1 0 2015 ? 00:00:01 [ksoftirqd/11]
root 37 1 0 2015 ? 00:00:00 [watchdog/11]
root 38 1 0 2015 ? 00:00:01 [migration/12]
root 39 1 0 2015 ? 00:00:00 [ksoftirqd/12]
root 40 1 0 2015 ? 00:00:00 [watchdog/12]
root 41 1 0 2015 ? 00:00:02 [migration/13]
root 42 1 0 2015 ? 00:00:00 [ksoftirqd/13]
root 43 1 0 2015 ? 00:00:00 [watchdog/13]
root 44 1 0 2015 ? 00:00:00 [migration/14]
root 45 1 0 2015 ? 00:00:00 [ksoftirqd/14]
root 46 1 0 2015 ? 00:00:00 [watchdog/14]
root 47 1 0 2015 ? 00:00:02 [migration/15]
root 48 1 0 2015 ? 00:00:00 [ksoftirqd/15]
root 49 1 0 2015 ? 00:00:00 [watchdog/15]
root 50 1 0 2015 ? 00:00:00 [events/0]
root 51 1 0 2015 ? 00:00:00 [events/1]
root 52 1 0 2015 ? 00:00:00 [events/2]
root 53 1 0 2015 ? 00:00:00 [events/3]
root 54 1 0 2015 ? 00:00:00 [events/4]
root 55 1 0 2015 ? 00:00:00 [events/5]
root 56 1 0 2015 ? 00:00:00 [events/6]
root 57 1 0 2015 ? 00:00:00 [events/7]
root 58 1 0 2015 ? 00:00:00 [events/8]
root 59 1 0 2015 ? 00:00:00 [events/9]
root 60 1 0 2015 ? 00:00:00 [events/10]
root 61 1 0 2015 ? 00:00:00 [events/11]
root 62 1 0 2015 ? 00:00:00 [events/12]
root 63 1 0 2015 ? 00:00:00 [events/13]
root 64 1 0 2015 ? 00:00:00 [events/14]
root 65 1 0 2015 ? 00:00:00 [events/15]
root 66 1 0 2015 ? 00:00:00 [khelper]
root 1107 1 0 2015 ? 00:00:00 [kthread]
root 1127 1107 0 2015 ? 00:00:00 [kblockd/0]
root 1128 1107 0 2015 ? 00:00:01 [kblockd/1]
root 1129 1107 0 2015 ? 00:00:00 [kblockd/2]
root 1130 1107 0 2015 ? 00:00:00 [kblockd/3]
root 1131 1107 0 2015 ? 00:00:00 [kblockd/4]
root 1132 1107 0 2015 ? 00:00:00 [kblockd/5]
root 1133 1107 0 2015 ? 00:00:00 [kblockd/6]
root 1134 1107 0 2015 ? 00:00:00 [kblockd/7]
root 1135 1107 0 2015 ? 00:00:00 [kblockd/8]
root 1136 1107 0 2015 ? 00:00:00 [kblockd/9]
root 1137 1107 0 2015 ? 00:00:00 [kblockd/10]
root 1138 1107 0 2015 ? 00:00:00 [kblockd/11]
root 1139 1107 0 2015 ? 00:00:00 [kblockd/12]
root 1140 1107 0 2015 ? 00:00:00 [kblockd/13]
root 1141 1107 0 2015 ? 00:00:00 [kblockd/14]
root 1142 1107 0 2015 ? 00:00:00 [kblockd/15]
root 1143 1107 0 2015 ? 00:00:00 [kacpid]
root 1568 1107 0 2015 ? 00:00:00 [cqueue/0]
root 1569 1107 0 2015 ? 00:00:00 [cqueue/1]
root 1570 1107 0 2015 ? 00:00:00 [cqueue/2]
root 1571 1107 0 2015 ? 00:00:00 [cqueue/3]
root 1572 1107 0 2015 ? 00:00:00 [cqueue/4]
root 1573 1107 0 2015 ? 00:00:00 [cqueue/5]
root 1574 1107 0 2015 ? 00:00:00 [cqueue/6]
root 1575 1107 0 2015 ? 00:00:00 [cqueue/7]
root 1576 1107 0 2015 ? 00:00:00 [cqueue/8]
root 1577 1107 0 2015 ? 00:00:00 [cqueue/9]
root 1578 1107 0 2015 ? 00:00:00 [cqueue/10]
root 1579 1107 0 2015 ? 00:00:00 [cqueue/11]
root 1580 1107 0 2015 ? 00:00:00 [cqueue/12]
root 1581 1107 0 2015 ? 00:00:00 [cqueue/13]
root 1582 1107 0 2015 ? 00:00:00 [cqueue/14]
root 1583 1107 0 2015 ? 00:00:00 [cqueue/15]
root 1586 1107 0 2015 ? 00:00:00 [khubd]
root 1588 1107 0 2015 ? 00:00:00 [kseriod]
root 1778 1107 0 2015 ? 00:00:02 [khungtaskd]
root 1781 1107 0 2015 ? 00:00:02 [kswapd0]
root 1782 1107 0 2015 ? 00:00:33 [kswapd1]
root 1783 1107 0 2015 ? 00:00:00 [aio/0]
root 1784 1107 0 2015 ? 00:00:00 [aio/1]
root 1785 1107 0 2015 ? 00:00:00 [aio/2]
root 1786 1107 0 2015 ? 00:00:00 [aio/3]
root 1787 1107 0 2015 ? 00:00:00 [aio/4]
root 1788 1107 0 2015 ? 00:00:00 [aio/5]
root 1789 1107 0 2015 ? 00:00:00 [aio/6]
root 1790 1107 0 2015 ? 00:00:00 [aio/7]
root 1791 1107 0 2015 ? 00:00:00 [aio/8]
root 1792 1107 0 2015 ? 00:00:00 [aio/9]
root 1793 1107 0 2015 ? 00:00:00 [aio/10]
root 1794 1107 0 2015 ? 00:00:00 [aio/11]
root 1795 1107 0 2015 ? 00:00:00 [aio/12]
root 1796 1107 0 2015 ? 00:00:00 [aio/13]
root 1797 1107 0 2015 ? 00:00:00 [aio/14]
root 1798 1107 0 2015 ? 00:00:00 [aio/15]
root 1955 1107 0 2015 ? 00:00:00 [kpsmoused]
root 2096 1107 0 2015 ? 00:00:00 [ata/0]
root 2097 1107 0 2015 ? 00:00:00 [ata/1]
root 2098 1107 0 2015 ? 00:00:00 [ata/2]
root 2099 1107 0 2015 ? 00:00:00 [ata/3]
root 2100 1107 0 2015 ? 00:00:00 [ata/4]
root 2101 1107 0 2015 ? 00:00:00 [ata/5]
root 2102 1107 0 2015 ? 00:00:00 [ata/6]
root 2103 1107 0 2015 ? 00:00:00 [ata/7]
root 2104 1107 0 2015 ? 00:00:00 [ata/8]
root 2105 1107 0 2015 ? 00:00:00 [ata/9]
root 2106 1107 0 2015 ? 00:00:00 [ata/10]
root 2107 1107 0 2015 ? 00:00:00 [ata/11]
root 2108 1107 0 2015 ? 00:00:00 [ata/12]
root 2109 1107 0 2015 ? 00:00:00 [ata/13]
root 2110 1107 0 2015 ? 00:00:00 [ata/14]
root 2111 1107 0 2015 ? 00:00:00 [ata/15]
root 2112 1107 0 2015 ? 00:00:00 [ata_aux]
root 2130 1107 0 2015 ? 00:00:00 [scsi_eh_0]
root 2131 1107 0 2015 ? 00:00:00 [scsi_eh_1]
root 2132 1107 0 2015 ? 00:00:00 [scsi_eh_2]
root 2133 1107 0 2015 ? 00:00:00 [scsi_eh_3]
root 2134 1107 0 2015 ? 00:00:00 [scsi_eh_4]
root 2135 1107 0 2015 ? 00:00:00 [scsi_eh_5]
root 2136 1107 0 2015 ? 00:00:00 [scsi_eh_6]
root 2137 1107 0 2015 ? 00:00:00 [scsi_eh_7]
root 2138 1107 0 2015 ? 00:00:00 [scsi_eh_8]
root 2139 1107 0 2015 ? 00:00:00 [scsi_eh_9]
root 2157 1107 0 2015 ? 00:00:00 [kstriped]
root 2226 1107 0 2015 ? 00:00:00 [ksnapd]
root 2297 1107 0 2015 ? 00:26:11 [kjournald]
root 2323 1107 0 2015 ? 00:00:00 [kauditd]
root 2356 1 0 2015 ? 00:00:00 /sbin/udevd -d
root 4007 1107 0 2015 ? 00:00:00 [cxgb4]
root 5009 1107 0 2015 ? 00:00:00 [kmpathd/0]
root 5010 1107 0 2015 ? 00:00:00 [kmpathd/1]
root 5011 1107 0 2015 ? 00:00:00 [kmpathd/2]
root 5012 1107 0 2015 ? 00:00:00 [kmpathd/3]
root 5013 1107 0 2015 ? 00:00:00 [kmpathd/4]
root 5014 1107 0 2015 ? 00:00:00 [kmpathd/5]
root 5015 1107 0 2015 ? 00:00:00 [kmpathd/6]
root 5016 1107 0 2015 ? 00:00:00 [kmpathd/7]
root 5017 1107 0 2015 ? 00:00:00 [kmpathd/8]
root 5018 1107 0 2015 ? 00:00:00 [kmpathd/9]
root 5019 1107 0 2015 ? 00:00:00 [kmpathd/10]
root 5020 1107 0 2015 ? 00:00:00 [kmpathd/11]
root 5021 1107 0 2015 ? 00:00:00 [kmpathd/12]
root 5022 1107 0 2015 ? 00:00:00 [kmpathd/13]
root 5023 1107 0 2015 ? 00:00:00 [kmpathd/14]
root 5024 1107 0 2015 ? 00:00:00 [kmpathd/15]
root 5025 1107 0 2015 ? 00:00:00 [kmpath_handlerd]
root 5098 1107 0 2015 ? 00:00:00 [kjournald]
root 5285 1107 0 2015 ? 00:00:00 [iscsi_eh]
root 5345 1 0 2015 ? 00:00:00 brcm_iscsiuio
root 5351 1 0 2015 ? 00:00:20 iscsid
root 5352 1 0 2015 ? 00:00:37 iscsid
root 5593 1 0 2015 ? 00:00:26 auditd
root 5595 5593 0 2015 ? 00:00:08 /sbin/audispd
root 5617 1 0 2015 ? 00:00:06 syslogd -m 0
root 5620 1 0 2015 ? 00:00:00 klogd -x
root 5873 1 0 2015 ? 00:03:40 irqbalance
root 5936 1107 0 2015 ? 00:00:01 [rpciod/0]
root 5937 1107 0 2015 ? 00:00:17 [rpciod/1]
root 5938 1107 0 2015 ? 00:01:15 [rpciod/2]
root 5939 1107 0 2015 ? 00:00:15 [rpciod/3]
root 5940 1107 0 2015 ? 00:01:15 [rpciod/4]
root 5941 1107 0 2015 ? 00:00:14 [rpciod/5]
root 5942 1107 0 2015 ? 00:01:14 [rpciod/6]
root 5943 1107 0 2015 ? 00:00:17 [rpciod/7]
root 5944 1107 0 2015 ? 00:00:02 [rpciod/8]
root 5945 1107 0 2015 ? 00:00:23 [rpciod/9]
root 5946 1107 0 2015 ? 00:01:42 [rpciod/10]
root 5947 1107 0 2015 ? 00:00:28 [rpciod/11]
root 5948 1107 0 2015 ? 00:02:29 [rpciod/12]
root 5949 1107 0 2015 ? 00:03:11 [rpciod/13]
root 5950 1107 0 2015 ? 00:05:15 [rpciod/14]
root 5951 1107 0 2015 ? 00:18:52 [rpciod/15]
rpcuser 5972 1 0 2015 ? 00:00:00 rpc.statd
root 6000 1 0 2015 ? 00:00:01 rpc.idmapd
dbus 6015 1 0 2015 ? 00:00:08 dbus-daemon --system
root 6030 1 0 2015 ? 00:00:00 /usr/sbin/hcid
root 6034 1 0 2015 ? 00:00:00 /usr/sbin/sdpd
root 6100 1 0 2015 ? 00:00:00 [krfcommd]
root 6160 1107 0 2015 ? 00:14:11 [nfsiod]
root 6161 1 0 2015 ? 00:00:00 [lockd]
root 6190 1 0 2015 ? 00:00:38 pcscd
root 6200 1 0 2015 ? 00:00:00 /usr/sbin/acpid
68 6209 1 0 2015 ? 00:00:12 hald
root 6210 6209 0 2015 ? 00:00:00 hald-runner
68 6218 6210 0 2015 ? 00:00:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
68 6224 6210 0 2015 ? 00:00:00 hald-addon-keyboard: listening on /dev/input/event1
68 6227 6210 0 2015 ? 00:00:00 hald-addon-keyboard: listening on /dev/input/event0
root 6240 6345 0 Jan04 ? 00:00:00 sshd: root@pts/1
root 6242 6240 0 Jan04 pts/1 00:00:00 -bash
root 6266 1 0 2015 ? 00:00:00 /usr/bin/hidd --server
root 6327 1 0 2015 ? 00:00:00 ./hpiod
root 6332 1 0 2015 ? 00:00:11 /usr/bin/python ./hpssd.py
root 6345 1 0 2015 ? 00:00:00 /usr/sbin/sshd
root 6354 1 0 2015 ? 00:00:44 cupsd
root 6367 1 0 2015 ? 00:00:14 xinetd -stayalive -pidfile /var/run/xinetd.pid
root 6385 1 0 2015 ? 00:00:11 sendmail: accepting connections
smmsp 6393 1 0 2015 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root 6403 1 0 2015 ? 00:00:16 gpm -m /dev/input/mice -t exps2
root 6412 1 0 2015 ? 00:00:04 crond
xfs 6441 1 0 2015 ? 00:00:00 xfs -droppriv -daemon
root 6458 1 0 2015 ? 00:00:01 /usr/sbin/atd
root 6482 1 0 2015 ? 00:00:00 /usr/bin/rhsmcertd 240
avahi 6501 1 0 2015 ? 00:00:00 avahi-daemon: running [cin230.local]
avahi 6502 6501 0 2015 ? 00:00:00 avahi-daemon: chroot helper
root 6563 1 0 2015 ? 00:00:00 /usr/sbin/smartd -q never
root 6568 1 0 2015 tty1 00:00:00 /sbin/mingetty tty1
root 6569 1 0 2015 tty2 00:00:00 /sbin/mingetty tty2
root 6570 1 0 2015 tty3 00:00:00 /sbin/mingetty tty3
root 6571 1 0 2015 tty4 00:00:00 /sbin/mingetty tty4
root 6572 1 0 2015 tty5 00:00:00 /sbin/mingetty tty5
root 6573 1 0 2015 tty6 00:00:00 /sbin/mingetty tty6
root 6574 1 0 2015 ? 00:00:00 /usr/sbin/gdm-binary -nodaemon
root 6615 6574 0 2015 ? 00:00:00 /usr/sbin/gdm-binary -nodaemon
root 6617 1 0 2015 ? 00:00:38 /usr/libexec/gdm-rh-security-token-helper
root 6618 6615 0 2015 tty7 00:00:02 /usr/bin/Xorg :0 -br -audit 0 -auth /var/gdm/:0.Xauth -nolisten tcp vt7
root 6623 1 0 2015 ? 00:00:01 /usr/bin/python -tt /usr/sbin/yum-updatesd
root 6625 1 0 2015 ? 00:00:09 /usr/libexec/gam_server
gdm 6636 6615 0 2015 ? 00:00:00 /usr/libexec/gdmgreeter
sge 7606 9481 0 01:14 ? 00:00:00 sge_shepherd-3031376 -bg
ajitb 7611 7606 0 01:14 ? 00:00:00 bash /opt/sge/default/spool/cin230/job_scripts/3031376
ajitb 7615 7611 7 01:14 ? 00:00:02 perl /home/ajitb/work/T6/maketools/cobble.pl /home/ajitb/work/T6/verif/ma_mc/diags/diags.cbl --runsim=1 --relname local --compile incremental --mode=interactive --domake=1 --domake_diag=0 -
rpc 8430 1 0 2015 ? 00:00:00 portmap
root 8450 1 0 2015 ? 00:00:10 ypbind
root 9097 1107 0 2015 ? 00:01:00 [pdflush]
sge 9481 1 0 2015 ? 02:53:04 /opt/sge/bin/lx-amd64/sge_execd
ajitb 10204 7615 0 01:14 ? 00:00:00 perl /home/ajitb/work/T6/maketools/vpp.pl /home/ajitb/work/T6/verif/lib/sv/misc/print_macros.svi /dv4/home/ajitb/work/T6/verif/ma_mc/sim/build.local.ASIC.ntb/ENV/SV/print_macros.svi /home/a
ajitb 10205 10204 0 01:14 ? 00:00:00 sh -c perl >/dv4/home/ajitb/work/T6/verif/ma_mc/sim/build.local.ASIC.ntb/ENV/SV/print_macros.svi
ajitb 10206 10205 0 01:14 ? 00:00:00 perl
root 10207 6242 0 01:14 pts/1 00:00:00 ps -ef
root 11188 1 0 2015 ? 00:01:34 automount
root 18573 1107 0 2015 ? 00:00:21 [pdflush]
root 26219 6345 0 2015 ? 00:00:00 sshd: anindita [priv]
anindita 26348 26219 0 2015 ? 00:00:00 sshd: anindita@pts/2
anindita 26349 26348 0 2015 pts/2 00:00:00 -tcsh
sge 27296 9481 0 Jan04 ? 00:00:00 sge_shepherd-3022732 -bg
regress 27298 27296 0 Jan04 ? 00:00:00 bash /opt/sge/default/spool/cin230/job_scripts/3022732
regress 27299 27298 0 Jan04 ? 00:00:00 bash /opt/sge/default/spool/cin230/job_scripts/3022732
regress 27300 27299 0 Jan04 ? 00:00:00 sleep 41411
regress 27307 27298 61 Jan04 ? 02:26:29 ./simv +vcs+nostdout +test_dir=/share//home/regress/t6_nightly_Sat/verif/ma_mc/system_ma_mc_pass/run.local.ASIC.ntb/mc_test/rand_clients_rd_wr_test1 +log_path=/share//home/regress/t6_nightl
sge 28996 9481 0 Jan04 ? 00:00:00 sge_shepherd-3031200 -bg
1363 29001 28996 0 Jan04 ? 00:00:00 /opt/sge/utilbin/lx-amd64/qrsh_starter /opt/sge/default/spool/cin230/active_jobs/3031200.1
1363 29008 29001 0 Jan04 ? 00:00:00 tcsh -c /dv6//home/saravanakumars/T6_tree/verif/top/sys_Ing/run.local.ASIC.ntb/tls/tls_ingress_cbc_sim.sh
1363 29018 29008 0 Jan04 ? 00:00:00 /bin/bash /dv6//home/saravanakumars/T6_tree/verif/top/sys_Ing/run.local.ASIC.ntb/tls/tls_ingress_cbc_sim.sh
1363 29025 29018 99 Jan04 ? 02:36:27 ./simv -ucli -i /dv6//home/saravanakumars/T6_tree/verif/top/sys_Ing/build.local.ASIC.ntb/ucli_dump.tcl +test_dir=/share//home/saravanakumars/T6_tree/verif/top/sys_Ing/run.local.ASIC.ntb/tls
sge 29549 9481 0 Jan04 ? 00:00:00 sge_shepherd-3022750 -bg
regress 29551 29549 0 Jan04 ? 00:00:00 bash /opt/sge/default/spool/cin230/job_scripts/3022750
regress 29552 29551 0 Jan04 ? 00:00:00 bash /opt/sge/default/spool/cin230/job_scripts/3022750
regress 29553 29552 0 Jan04 ? 00:00:00 sleep 41411
regress 29560 29551 99 Jan04 ? 01:39:22 ./simv +vcs+nostdout +test_dir=/share//home/regress/t6_nightly_Sat/verif/ma_mc/system_ma_mc_pass/run.local.ASIC.ntb/mc_test/wr_arb_mul_cli_test +log_path=/share//home/regress/t6_nightly_Sat
ntp 31129 1 0 2015 ? 00:30:35 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
[root@cin230 ~]#
 
Old 01-05-2016, 03:35 AM   #6
fmattheus
Member
 
Registered: Nov 2015
Posts: 104

Rep: Reputation: 38
Ahh ... ok, now I think I understand what you're trying to do.
simv is started by a parent process. When that parent process is run from a script in /opt/sge/default, you want to know the pid of the simv process.

This command should do that
Code:
for ppid in $(ps -ef | grep /opt/sge/default | awk '{print $2}'); do ps -ef | grep simv | awk "\$3 ~ /$ppid/ {print \$2}"; done
Let's break that down

Code:
ps -ef | grep /opt/sge/default | awk '{print $2}'
gives a list of all pids containing /opt/sge/default.

It loops through them all in a for loop with a variable named ppid.

Code:
ps -ef | grep simv
Lists all processes that contain simv

Code:
ps -ef | grep simv | awk "\$3 ~ /$ppid/ {print \$2}"
The awk here checks if the third column is the current ppid, if so it prints the pid of the simv process.
Note: the awk variables $3 and $2 need to be escaped that's why the extra \ is there.
 
Old 01-05-2016, 10:28 AM   #7
asteroid4u
Member
 
Registered: Jun 2015
Posts: 58

Original Poster
Rep: Reputation: Disabled
Hi fmattheus,

Thanks for helping me again.

1. simv process spanned by /opt/sge/default
2. Some times simv process directly started (not using /opt/sge/default)
3. Now i want find whether my simv process is started by /opt/sge/default or directly started without using /opt/sge/default
 
Old 01-05-2016, 11:03 AM   #8
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by asteroidmilky@gmail.com View Post
3. Now i want find whether my simv process is started by /opt/sge/default or directly started without using /opt/sge/default
Try this slight variation
Code:
for ppid in $(ps -ef | grep -v /opt/sge/default | awk '{print $2}'); do ps -ef | grep simv | awk "\$3 ~ /$ppid/ {print \$2}"; done
compare the first with the second and you'll know which and from where.

Alternate: Read the directory with lsof, eg:
Code:
lsof +D /opt/sge/default
and process that result.

Last edited by Habitual; 01-05-2016 at 11:42 AM.
 
Old 01-05-2016, 10:31 PM   #9
asteroid4u
Member
 
Registered: Jun 2015
Posts: 58

Original Poster
Rep: Reputation: Disabled
Hi Habitual,

Could you Please explain me what below command does

for ppid in $(ps -ef | grep -v /opt/sge/default | awk '{print $2}'); do ps -ef | grep simv | awk "\$3 ~ /$ppid/ {print \$2}"; done

Thanks,
 
Old 01-06-2016, 11:03 AM   #10
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
the command shows you what's running called simv but not running out of /opt/sge/default
 
Old 01-07-2016, 09:43 PM   #11
asteroid4u
Member
 
Registered: Jun 2015
Posts: 58

Original Poster
Rep: Reputation: Disabled
Hi Habitual,

I am finding simv process ID's by below command

[root@cin230 ~]# ps xao user,pid,ppid,comm | grep 'simv'
2261 12747 12738 simv
basheer 16738 16729 simv

and then I am greping simv process ID by below to find whether simv process ID is started by /opt/sge/default or not. Is my understanding is correct?
[root@cin230 ~]# for ppid in $(ps -ef | grep -v /opt/sge/default | awk '{print $2}'); do ps -ef | grep simv | awk "\$3 ~ /$ppid/ {print \$2}"; done | grep 12747
12747
12747
12747
12747
12747
12747
12747
12747
[root@cin230 ~]# for ppid in $(ps -ef | grep -v /opt/sge/default | awk '{print $2}'); do ps -ef | grep simv | awk "\$3 ~ /$ppid/ {print \$2}"; done | grep 16738
16738
16738
16738
16738
16738
16738
16738
 
Old 01-08-2016, 01:53 AM   #12
fmattheus
Member
 
Registered: Nov 2015
Posts: 104

Rep: Reputation: 38
Why did you add the grep to the end of the for command?
 
  


Reply

Tags
linux, processes, programing, shell scripting, unix



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help to find the process running by particular user and kill process one by one LittleMaster Linux - Newbie 1 02-09-2013 02:03 PM
How to find which process started a daemon process in autostart? indiajoe Linux - Desktop 4 10-25-2011 02:19 AM
I'm a complete noob so be patient with me dVbzx Linux - Newbie 9 09-12-2010 07:28 AM
Who is going to be patient with me..? iwmpop Linux - Newbie 4 01-23-2010 12:55 AM
How to find the process ID of process executing in the background akeneche Linux - Newbie 1 01-03-2008 10:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration