[oracle@usha ~]$ ps -ef|grep "ora_"|grep -v grep|grep $ORACLE_SID|awk '{ print $2 }'
http://www.math.harvard.edu/computing/unix/unixcommands.html
http://www.math.harvard.edu/computing/unix/unixcommands.html
Above UNIX command is the combination of 5 commands, ps-ef | grep "ora_" | grep -v grep | grep $ORACLE_SID | awk '{ print $2 }' lets see output of each command [oracle@usha ~]$ ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 Jan23 ? 00:00:14 /sbin/init root 2 0 0 Jan23 ? 00:00:00 [kthreadd] root 3 2 0 Jan23 ? 00:00:32 [ksoftirqd/0] root 6 2 0 Jan23 ? 00:00:00 [migration/0] root 7 2 0 Jan23 ? 00:00:03 [watchdog/0] root 13 2 0 Jan23 ? 00:00:00 [cpuset] root 14 2 0 Jan23 ? 00:00:00 [khelper] root 15 2 0 Jan23 ? 00:00:00 [kdevtmpfs] root 16 2 0 Jan23 ? 00:00:00 [netns] root 17 2 0 Jan23 ? 00:00:01 [sync_supers] root 18 2 0 Jan23 ? 00:00:00 [bdi-default] root 19 2 0 Jan23 ? 00:00:00 [kintegrityd] root 20 2 0 Jan23 ? 00:00:00 [kblockd] root 21 2 0 Jan23 ? 00:00:00 [ata_sff] root 22 2 0 Jan23 ? 00:00:00 [khubd] root 23 2 0 Jan23 ? 00:00:00 [md] root 26 2 0 Jan23 ? 00:00:09 [kswapd0] root 27 2 0 Jan23 ? 00:00:00 [ksmd] root 28 2 0 Jan23 ? 00:00:22 [khugepaged] root 29 2 0 Jan23 ? 00:00:00 [fsnotify_mark] root 30 2 0 Jan23 ? 00:00:00 [crypto] root 36 2 0 Jan23 ? 00:00:00 [kthrotld] root 38 2 0 Jan23 ? 00:00:00 [scsi_eh_0] root 39 2 0 Jan23 ? 00:01:08 [scsi_eh_1] root 41 2 0 Jan23 ? 00:00:00 [kpsmoused] root 349 2 0 Jan23 ? 00:00:00 [pccardd] root 386 2 0 Jan23 ? 00:00:00 [kdmflush] root 390 2 0 Jan23 ? 00:00:00 [kdmflush] root 420 2 0 Jan23 ? 00:00:18 [jbd2/dm-1-8] root 421 2 0 Jan23 ? 00:00:00 [ext4-dio-unwrit] root 452 2 0 Jan23 ? 00:00:00 [kauditd] root 459 1 0 Jan23 ? 00:00:00 /lib/systemd/systemd-logger root 470 1 0 Jan23 ? 00:00:01 /sbin/udevd root 475 2 0 Jan23 ? 00:00:04 [flush-253:1] root 729 2 0 Jan23 ? 00:00:00 [cfg80211] root 741 2 0 Jan23 ? 00:00:00 [hd-audio0] root 787 2 0 Jan23 ? 00:00:00 [jbd2/sda1-8] root 788 2 0 Jan23 ? 00:00:00 [ext4-dio-unwrit] root 804 2 0 Jan23 ? 00:00:00 [kdmflush] root 829 2 0 Jan23 ? 00:00:18 [jbd2/dm-2-8] root 830 2 0 Jan23 ? 00:00:00 [ext4-dio-unwrit] root 850 1 0 Jan23 ? 00:01:26 /usr/sbin/NetworkManager --no-daemon root 852 1 0 Jan23 ? 00:00:07 /usr/sbin/acpid avahi 854 1 0 Jan23 ? 00:00:00 avahi-daemon: running [usha.local] root 861 1 0 Jan23 ? 00:00:00 /usr/sbin/abrtd -d -s root 874 1 0 Jan23 ? 00:01:23 /usr/sbin/irqbalance root 875 1 0 Jan23 ? 00:00:00 /usr/sbin/smartd -n -q never root 876 1 0 Jan23 ? 00:00:04 /usr/sbin/crond -n root 903 1 0 Jan23 ? 00:00:01 /sbin/rsyslogd -n -c 5 dbus 906 1 0 Jan23 ? 00:01:23 /bin/dbus-daemon --system --address=systemd: --nofork --sys avahi 915 854 0 Jan23 ? 00:00:00 avahi-daemon: chroot helper root 931 2 0 Jan23 ? 00:00:19 [flush-253:2] root 950 1 0 Jan23 ? 00:00:00 /usr/sbin/mcelog --ignorenodev --daemon --foreground root 957 1 0 Jan23 ? 00:00:01 auditd root 959 957 0 Jan23 ? 00:00:01 /sbin/audispd root 967 959 0 Jan23 ? 00:00:00 /usr/sbin/sedispatch root 981 1 0 Jan23 ? 00:00:02 /usr/libexec/polkit-1/polkitd root 1008 1 0 Jan23 ? 00:00:00 /usr/sbin/modem-manager root 1018 1 0 Jan23 ? 00:00:00 rpcbind root 1130 2 0 Jan23 ? 00:00:00 [rpciod] rpcuser 1143 1 0 Jan23 ? 00:00:00 rpc.statd root 1145 1 0 Jan23 ? 00:00:00 abrt-dump-oops -d /var/spool/abrt -rwx /var/log/messages root 1170 1 0 Jan23 ? 00:00:00 /usr/sbin/gdm-binary -nodaemon root 1171 1 0 Jan23 ? 00:00:00 pcscd root 1172 1 0 Jan23 ? 00:00:00 rpc.idmapd root 1178 1 0 Jan23 ? 00:00:34 /usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplic root 1184 1 0 Jan23 ? 00:00:00 cupsd -C /etc/cups/cupsd.conf root 1187 1170 0 Jan23 ? 00:00:00 /usr/libexec/gdm-simple-slave --display-id /org/gnome/Displ root 1191 1 0 Jan23 ? 00:00:00 mdadm --monitor --scan -f --pid-file=/var/run/mdadm/mdadm.p root 1193 1 0 Jan23 ? 00:00:00 /usr/sbin/sshd root 1196 1 0 Jan23 ? 00:00:00 /usr/libexec/colord root 1197 1187 0 Jan23 tty1 01:43:48 /usr/bin/Xorg :0 -background none -verbose -auth /var/run/g root 1213 1 0 Jan23 tty2 00:00:00 /sbin/agetty tty2 38400 root 1214 1 0 Jan23 tty6 00:00:00 /sbin/agetty tty6 38400 root 1215 1 0 Jan23 tty3 00:00:00 /sbin/agetty tty3 38400 root 1217 1 0 Jan23 tty5 00:00:00 /sbin/agetty tty5 38400 root 1218 1 0 Jan23 tty4 00:00:00 /sbin/agetty tty4 38400 root 1234 1 0 Jan23 ? 00:00:01 /usr/sbin/console-kit-daemon --no-daemon rtkit 1333 1 0 Jan23 ? 00:00:04 /usr/libexec/rtkit-daemon root 1365 1 0 Jan23 ? 00:00:33 /usr/libexec/udisks-daemon root 1366 1365 0 Jan23 ? 00:00:59 udisks-daemon: polling /dev/sr0 root 1370 1 0 Jan23 ? 00:00:01 /usr/libexec/upowerd root 1420 1187 0 Jan23 ? 00:00:00 pam: gdm-password root 1423 1 0 Jan23 ? 00:00:00 /usr/libexec/accounts-daemon oracle 1434 1 0 Jan23 ? 00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --login oracle 1442 1420 0 Jan23 ? 00:00:01 gnome-session oracle 1453 1 0 Jan23 ? 00:00:00 dbus-launch --sh-syntax --exit-with-session oracle 1454 1 0 Jan23 ? 00:02:20 /bin/dbus-daemon --fork --print-pid 5 --print-address 7 --s oracle 1513 1 0 Jan23 ? 00:00:00 /usr/libexec/imsettings-daemon oracle 1516 1 0 Jan23 ? 00:00:00 /usr/libexec/gvfsd oracle 1547 1 0 Jan23 ? 00:00:00 /usr/libexec//gvfs-fuse-daemon /home/oracle/.gvfs oracle 1581 1 0 Jan23 ? 00:00:03 /usr/libexec/gconfd-2 oracle 1588 1442 0 Jan23 ? 00:01:01 /usr/libexec/gnome-settings-daemon oracle 1598 1 0 Jan23 ? 00:04:02 /usr/bin/pulseaudio --start oracle 1601 1598 0 Jan23 ? 00:00:00 /usr/libexec/pulse/gconf-helper oracle 1644 1 0 Jan23 ? 00:00:01 /usr/libexec/gvfs-gdu-volume-monitor oracle 1646 1 0 Jan23 ? 00:00:27 /usr/libexec/gvfs-afc-volume-monitor oracle 1649 1 0 Jan23 ? 00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor oracle 1651 1 0 Jan23 ? 00:00:00 /usr/libexec/gsd-printer oracle 1657 1442 0 Jan23 ? 00:58:52 /usr/bin/gnome-shell oracle 1663 1442 0 Jan23 ? 00:01:02 nm-applet oracle 1664 1442 0 Jan23 ? 00:00:09 gnome-power-manager oracle 1665 1442 0 Jan23 ? 00:00:00 /usr/bin/seapplet oracle 1668 1442 0 Jan23 ? 00:00:00 /usr/lib64/deja-dup/deja-dup-monitor oracle 1673 1442 0 Jan23 ? 00:00:00 /usr/libexec/gdu-notification-daemon oracle 1676 1442 0 Jan23 ? 00:00:00 abrt-applet oracle 1689 1442 0 Jan23 ? 00:00:00 /usr/libexec/evolution/3.0/evolution-alarm-notify oracle 1705 1442 0 Jan23 ? 00:00:31 gnome-screensaver oracle 1727 1 0 Jan23 ? 00:00:00 /usr/libexec/dconf-service oracle 1731 1442 0 Jan23 ? 00:00:01 /usr/libexec/vino-server oracle 1743 1 0 Jan23 ? 00:00:00 /usr/libexec/e-calendar-factory oracle 1748 1 0 Jan23 ? 00:00:00 /usr/libexec/e-addressbook-factory oracle 1754 1 0 Jan23 ? 00:00:00 /usr/libexec/gnome-shell-calendar-server oracle 1760 1 0 Jan23 ? 00:00:00 /usr/libexec/mission-control-5 oracle 2207 16790 0 Jan31 pts/1 00:00:00 bash oracle 9469 1 0 Jan25 ? 00:00:00 /usr/libexec/gvfsd-trash --spawner :1.4 /org/gtk/gvfs/exec_ oracle 9474 1 0 Jan25 ? 00:00:00 /usr/libexec/gvfsd-burn --spawner :1.4 /org/gtk/gvfs/exec_s oracle 9480 1 0 Jan25 ? 00:00:00 /usr/libexec/gvfsd-metadata oracle 11913 1657 4 Feb02 ? 02:31:12 /usr/lib64/firefox/firefox oracle 11973 11913 2 Feb02 ? 01:30:51 /usr/lib64/nspluginwrapper/npviewer.bin --plugin /usr/lib64 oracle 16790 1657 0 Jan28 ? 00:00:51 gnome-terminal oracle 16796 16790 0 Jan28 ? 00:00:00 gnome-pty-helper oracle 16817 1 0 Jan28 ? 00:01:13 ora_pmon_DB11G oracle 16819 1 0 Jan28 ? 00:18:52 ora_vktm_DB11G oracle 16823 1 0 Jan28 ? 00:00:12 ora_gen0_DB11G oracle 16825 1 0 Jan28 ? 00:00:18 ora_diag_DB11G oracle 16827 1 0 Jan28 ? 00:00:13 ora_dbrm_DB11G oracle 16829 1 0 Jan28 ? 00:00:21 ora_psp0_DB11G oracle 16831 1 0 Jan28 ? 00:03:34 ora_dia0_DB11G oracle 16833 1 0 Jan28 ? 00:00:12 ora_mman_DB11G oracle 16835 1 0 Jan28 ? 00:00:39 ora_dbw0_DB11G oracle 16837 1 0 Jan28 ? 00:00:30 ora_lgwr_DB11G oracle 16839 1 0 Jan28 ? 00:01:21 ora_ckpt_DB11G oracle 16841 1 0 Jan28 ? 00:00:21 ora_smon_DB11G oracle 16843 1 0 Jan28 ? 00:00:04 ora_reco_DB11G oracle 16845 1 0 Jan28 ? 00:00:42 ora_mmon_DB11G oracle 16847 1 0 Jan28 ? 00:01:59 ora_mmnl_DB11G oracle 16849 1 0 Jan28 ? 00:00:05 ora_d000_DB11G oracle 16851 1 0 Jan28 ? 00:00:04 ora_s000_DB11G oracle 16864 1 0 Jan28 ? 00:00:05 ora_qmnc_DB11G oracle 16878 1 0 Jan28 ? 00:01:21 ora_cjq0_DB11G oracle 16882 1 0 Jan28 ? 00:00:03 ora_q001_DB11G oracle 16933 1 0 Jan28 ? 00:00:14 ora_smco_DB11G oracle 29182 1 0 02:02 ? 00:00:00 ora_q002_DB11G root 30662 2 0 09:44 ? 00:00:00 [migration/1] root 30664 2 0 09:44 ? 00:00:00 [ksoftirqd/1] root 30665 2 0 09:44 ? 00:00:00 [watchdog/1] root 30668 2 0 09:44 ? 00:00:02 [kworker/1:2] root 30700 470 0 09:44 ? 00:00:00 /sbin/udevd root 30701 470 0 09:44 ? 00:00:00 /sbin/udevd root 30735 1 0 09:44 ? 00:00:00 /usr/sbin/atd -f oracle 30766 1 0 09:44 ? 00:00:07 ora_vkrm_DB11G root 30776 2 0 09:44 ? 00:00:02 [irq/17-b43] root 30792 850 0 09:44 ? 00:00:00 /sbin/dhclient -d -4 -sf /usr/libexec/nm-dhcp-client.action root 30912 2 0 09:55 ? 00:00:00 [kworker/0:2] root 30977 2 0 10:02 ? 00:00:02 [kworker/0:3] root 30993 2 0 10:04 ? 00:00:00 [kworker/1:1] root 31066 2 0 10:14 ? 00:00:00 [kworker/u:0] root 31076 2 0 10:15 ? 00:00:00 [kworker/0:1] root 31079 2 0 10:15 ? 00:00:00 [kworker/1:0] root 31138 2 0 10:20 ? 00:00:00 [kworker/u:2] root 31154 2 0 10:23 ? 00:00:00 [kworker/0:0] oracle 31161 1 0 10:24 ? 00:00:00 ora_w000_DB11G root 31169 2 0 10:25 ? 00:00:00 [kworker/1:3] root 31176 2 0 10:26 ? 00:00:00 [kworker/u:1] oracle 31181 2207 0 10:27 pts/1 00:00:00 ps -ef [oracle@usha ~]$ Now lets filter the above output on column CMD to show only ora_ [oracle@usha ~]$ ps -ef|grep "ora_" oracle 16817 1 0 Jan28 ? 00:01:13 ora_pmon_DB11G oracle 16819 1 0 Jan28 ? 00:18:52 ora_vktm_DB11G oracle 16823 1 0 Jan28 ? 00:00:12 ora_gen0_DB11G oracle 16825 1 0 Jan28 ? 00:00:18 ora_diag_DB11G oracle 16827 1 0 Jan28 ? 00:00:13 ora_dbrm_DB11G oracle 16829 1 0 Jan28 ? 00:00:21 ora_psp0_DB11G oracle 16831 1 0 Jan28 ? 00:03:35 ora_dia0_DB11G oracle 16833 1 0 Jan28 ? 00:00:12 ora_mman_DB11G oracle 16835 1 0 Jan28 ? 00:00:39 ora_dbw0_DB11G oracle 16837 1 0 Jan28 ? 00:00:30 ora_lgwr_DB11G oracle 16839 1 0 Jan28 ? 00:01:21 ora_ckpt_DB11G oracle 16841 1 0 Jan28 ? 00:00:21 ora_smon_DB11G oracle 16843 1 0 Jan28 ? 00:00:04 ora_reco_DB11G oracle 16845 1 0 Jan28 ? 00:00:42 ora_mmon_DB11G oracle 16847 1 0 Jan28 ? 00:01:59 ora_mmnl_DB11G oracle 16849 1 0 Jan28 ? 00:00:05 ora_d000_DB11G oracle 16851 1 0 Jan28 ? 00:00:04 ora_s000_DB11G oracle 16864 1 0 Jan28 ? 00:00:05 ora_qmnc_DB11G oracle 16878 1 0 Jan28 ? 00:01:21 ora_cjq0_DB11G oracle 16882 1 0 Jan28 ? 00:00:03 ora_q001_DB11G oracle 16933 1 0 Jan28 ? 00:00:14 ora_smco_DB11G oracle 29182 1 0 02:02 ? 00:00:00 ora_q002_DB11G oracle 30766 1 0 09:44 ? 00:00:07 ora_vkrm_DB11G oracle 31161 1 0 10:24 ? 00:00:00 ora_w000_DB11G oracle 31189 1 0 10:28 ? 00:00:00 ora_j000_DB11G oracle 31191 1 0 10:28 ? 00:00:00 ora_j001_DB11G oracle 31193 2207 0 10:28 pts/1 00:00:00 grep --color=auto ora_ [oracle@usha ~]$ Now Remove the last line which is the grep command we issued to display above data. [oracle@usha ~]$ ps -ef|grep "ora_"|grep -v grep oracle 16817 1 0 Jan28 ? 00:01:13 ora_pmon_DB11G oracle 16819 1 0 Jan28 ? 00:18:53 ora_vktm_DB11G oracle 16823 1 0 Jan28 ? 00:00:12 ora_gen0_DB11G oracle 16825 1 0 Jan28 ? 00:00:18 ora_diag_DB11G oracle 16827 1 0 Jan28 ? 00:00:13 ora_dbrm_DB11G oracle 16829 1 0 Jan28 ? 00:00:21 ora_psp0_DB11G oracle 16831 1 0 Jan28 ? 00:03:35 ora_dia0_DB11G oracle 16833 1 0 Jan28 ? 00:00:12 ora_mman_DB11G oracle 16835 1 0 Jan28 ? 00:00:39 ora_dbw0_DB11G oracle 16837 1 0 Jan28 ? 00:00:30 ora_lgwr_DB11G oracle 16839 1 0 Jan28 ? 00:01:21 ora_ckpt_DB11G oracle 16841 1 0 Jan28 ? 00:00:21 ora_smon_DB11G oracle 16843 1 0 Jan28 ? 00:00:04 ora_reco_DB11G oracle 16845 1 0 Jan28 ? 00:00:42 ora_mmon_DB11G oracle 16847 1 0 Jan28 ? 00:01:59 ora_mmnl_DB11G oracle 16849 1 0 Jan28 ? 00:00:05 ora_d000_DB11G oracle 16851 1 0 Jan28 ? 00:00:04 ora_s000_DB11G oracle 16864 1 0 Jan28 ? 00:00:05 ora_qmnc_DB11G oracle 16878 1 0 Jan28 ? 00:01:21 ora_cjq0_DB11G oracle 16882 1 0 Jan28 ? 00:00:03 ora_q001_DB11G oracle 16933 1 0 Jan28 ? 00:00:14 ora_smco_DB11G oracle 29182 1 0 02:02 ? 00:00:00 ora_q002_DB11G oracle 30766 1 0 09:44 ? 00:00:08 ora_vkrm_DB11G oracle 31161 1 0 10:24 ? 00:00:00 ora_w000_DB11G oracle 31210 1 0 10:31 ? 00:00:00 ora_j000_DB11G oracle 31212 1 0 10:31 ? 00:00:00 ora_j001_DB11G [oracle@usha ~]$ Now suppose there are multiple instances running on this server and your requirement is to show the processes for the instance you are interested. we will use environment variable ORACLE_SID to filter the output. in this case since only one instance is running so we will se the same result. [oracle@usha ~]$ ps -ef|grep "ora_"|grep -v grep|grep $ORACLE_SID oracle 16817 1 0 Jan28 ? 00:01:13 ora_pmon_DB11G oracle 16819 1 0 Jan28 ? 00:18:53 ora_vktm_DB11G oracle 16823 1 0 Jan28 ? 00:00:12 ora_gen0_DB11G oracle 16825 1 0 Jan28 ? 00:00:18 ora_diag_DB11G oracle 16827 1 0 Jan28 ? 00:00:13 ora_dbrm_DB11G oracle 16829 1 0 Jan28 ? 00:00:21 ora_psp0_DB11G oracle 16831 1 0 Jan28 ? 00:03:35 ora_dia0_DB11G oracle 16833 1 0 Jan28 ? 00:00:12 ora_mman_DB11G oracle 16835 1 0 Jan28 ? 00:00:39 ora_dbw0_DB11G oracle 16837 1 0 Jan28 ? 00:00:30 ora_lgwr_DB11G oracle 16839 1 0 Jan28 ? 00:01:21 ora_ckpt_DB11G oracle 16841 1 0 Jan28 ? 00:00:21 ora_smon_DB11G oracle 16843 1 0 Jan28 ? 00:00:04 ora_reco_DB11G oracle 16845 1 0 Jan28 ? 00:00:42 ora_mmon_DB11G oracle 16847 1 0 Jan28 ? 00:01:59 ora_mmnl_DB11G oracle 16849 1 0 Jan28 ? 00:00:05 ora_d000_DB11G oracle 16851 1 0 Jan28 ? 00:00:04 ora_s000_DB11G oracle 16864 1 0 Jan28 ? 00:00:05 ora_qmnc_DB11G oracle 16878 1 0 Jan28 ? 00:01:21 ora_cjq0_DB11G oracle 16882 1 0 Jan28 ? 00:00:03 ora_q001_DB11G oracle 16933 1 0 Jan28 ? 00:00:14 ora_smco_DB11G oracle 29182 1 0 02:02 ? 00:00:00 ora_q002_DB11G oracle 30766 1 0 09:44 ? 00:00:08 ora_vkrm_DB11G oracle 31161 1 0 10:24 ? 00:00:00 ora_w000_DB11G [oracle@usha ~]$ The above output has 7 columns and we are interested in 2nd column which is the PID ->Process ID. [oracle@usha ~]$ ps -ef|grep "ora_"|grep -v grep|grep $ORACLE_SID|awk '{ print $2 }' 16817 16819 16823 16825 16827 16829 16831 16833 16835 16837 16839 16841 16843 16845 16847 16849 16851 16864 16878 16882 16933 29182 30766 31232 31269 31271 [oracle@usha ~]$ |