Using grep and awk to filter our idle connections
Post date: Jul 08, 2015 2:5:32 PM
[sachi@localhost ~]$ ps -ef | awk '/sachi/ && /idle/'
gpadmin 13356 1436 0 09:13 ? 00:00:00 postgres: port 5432, sachi sachi [local] con120988 [local] idle
sachi 17449 13370 0 09:38 pts/1 00:00:00 awk /sachi/ && /idle/
[sachi@localhost ~]$ ps -ef | awk '/sachi/ && /idle/'|grep -v awk
gpadmin 13356 1436 0 09:13 ? 00:00:00 postgres: port 5432, sachi sachi [local] con120988 [local] idle
[sachi@localhost ~]$ ps -ef | awk '/sachi/ && /idle/'|grep -v awk
gpadmin 13356 1436 0 09:13 ? 00:00:00 postgres: port 5432, sachi sachi [local] con120988 [local] idle
[sachi@localhost ~]$ ps -ef |grep sachi
sachi 2380 2353 0 Jun26 ? 00:00:06 gnome-session --session gnome-classic
sachi 2388 1 0 Jun26 ? 00:00:00 dbus-launch --sh-syntax --exit-with-session
sachi 2396 1 0 Jun26 ? 00:00:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
sachi 2484 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfsd
sachi 2551 1 0 Jun26 ? 00:00:00 /usr/libexec//gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
sachi 2554 2380 0 Jun26 ? 00:00:02 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "env GNOME_SHELL_SESSION_MODE=classic gnome-session --session gnome-classic"
sachi 2595 1 0 Jun26 ? 00:00:00 /usr/libexec/at-spi-bus-launcher
sachi 2599 2595 0 Jun26 ? 00:00:00 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
sachi 2603 1 0 Jun26 ? 00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
sachi 2611 2380 0 Jun26 ? 00:00:22 /usr/libexec/gnome-settings-daemon
sachi 2627 1 0 Jun26 ? 00:00:02 /usr/bin/pulseaudio --start
sachi 2632 1 0 Jun26 ? 00:00:00 /usr/bin/gnome-keyring-daemon --start --components=ssh
sachi 2726 1 0 Jun26 ? 00:00:04 /usr/libexec/gvfs-udisks2-volume-monitor
sachi 2741 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-afc-volume-monitor
sachi 2746 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
sachi 2750 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor
sachi 2754 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-goa-volume-monitor
sachi 2757 1 0 Jun26 ? 00:00:00 /usr/libexec/goa-daemon
sachi 2764 1 0 Jun26 ? 00:00:43 /usr/libexec/goa-identity-service
sachi 2766 2380 0 Jun26 ? 00:01:31 /usr/bin/gnome-shell
sachi 2773 1 0 Jun26 ? 00:00:00 /usr/libexec/dconf-service
sachi 2781 1 0 Jun26 ? 00:00:00 /usr/libexec/gsd-printer
sachi 2798 1 0 Jun26 ? 00:00:00 /usr/bin/ibus-daemon --replace --xim --panel disable
sachi 2806 2798 0 Jun26 ? 00:00:00 /usr/libexec/ibus-dconf
sachi 2808 1 0 Jun26 ? 00:00:00 /usr/libexec/ibus-x11 --kill-daemon
sachi 2816 1 0 Jun26 ? 00:00:00 /usr/libexec/gnome-shell-calendar-server
sachi 2820 1 0 Jun26 ? 00:00:06 /usr/libexec/mission-control-5
sachi 2832 1 0 Jun26 ? 00:00:00 /usr/libexec/evolution-source-registry
sachi 2840 2798 0 Jun26 ? 00:00:00 /usr/libexec/ibus-engine-simple
sachi 2942 1 0 Jun26 ? 00:00:00 /usr/libexec/evolution-addressbook-factory
sachi 2947 1 0 Jun26 ? 00:00:01 /usr/libexec/gconfd-2
sachi 2954 1 0 Jun26 ? 00:00:00 /usr/libexec/tracker-store
sachi 2970 1 0 Jun26 ? 00:00:00 /usr/libexec/evolution-calendar-factory
sachi 3010 1 0 Jun26 ? 00:00:00 /usr/libexec/gnome-session-failed --allow-logout
sachi 3014 2380 0 Jun26 ? 00:00:00 /usr/bin/seapplet
sachi 3029 2380 0 Jun26 ? 00:00:00 abrt-applet
root 13024 948 0 09:11 ? 00:00:00 sshd: sachi [priv]
sachi 13033 13024 0 09:11 ? 00:00:00 sshd: sachi@pts/0
sachi 13039 13033 0 09:11 pts/0 00:00:00 -bash
sachi 13355 13039 0 09:13 pts/0 00:00:00 psql
gpadmin 13356 1436 0 09:13 ? 00:00:00 postgres: port 5432, sachi sachi [local] con120988 [local] idle
root 13358 948 0 09:13 ? 00:00:00 sshd: sachi [priv]
sachi 13363 13358 0 09:13 ? 00:00:00 sshd: sachi@pts/1
sachi 13370 13363 0 09:13 pts/1 00:00:00 -bash
sachi 17897 13370 0 09:40 pts/1 00:00:00 ps -ef
sachi 17898 13370 0 09:40 pts/1 00:00:00 grep --color=auto sachi
[sachi@localhost ~]$ ps -ef | awk '/sachi/ && /idle/'|grep -v awk
gpadmin 13356 1436 0 09:13 ? 00:00:00 postgres: port 5432, sachi sachi [local] con120988 [local] idle
[sachi@localhost ~]$ ps -ax | awk '/sachi/ && /idle/'|grep -v awk
13356 ? Ssl 0:00 postgres: port 5432, sachi sachi [local] con120988 [local] idle
[sachi@localhost ~]$ ps -ax | awk '/sachi/ && /idlee/'|grep -v awk
[sachi@localhost ~]$ ps -ax | awk '/sachi/ && /idle/'|grep -v awk
13356 ? Ssl 0:00 postgres: port 5432, sachi sachi [local] con120988 [local] idle
[sachi@localhost ~]$ ps -ef |grep sachi| grep -v idle
sachi 2380 2353 0 Jun26 ? 00:00:06 gnome-session --session gnome-classic
sachi 2388 1 0 Jun26 ? 00:00:00 dbus-launch --sh-syntax --exit-with-session
sachi 2396 1 0 Jun26 ? 00:00:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
sachi 2484 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfsd
sachi 2551 1 0 Jun26 ? 00:00:00 /usr/libexec//gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
sachi 2554 2380 0 Jun26 ? 00:00:02 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "env GNOME_SHELL_SESSION_MODE=classic gnome-session --session gnome-classic"
sachi 2595 1 0 Jun26 ? 00:00:00 /usr/libexec/at-spi-bus-launcher
sachi 2599 2595 0 Jun26 ? 00:00:00 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
sachi 2603 1 0 Jun26 ? 00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
sachi 2611 2380 0 Jun26 ? 00:00:22 /usr/libexec/gnome-settings-daemon
sachi 2627 1 0 Jun26 ? 00:00:02 /usr/bin/pulseaudio --start
sachi 2632 1 0 Jun26 ? 00:00:00 /usr/bin/gnome-keyring-daemon --start --components=ssh
sachi 2726 1 0 Jun26 ? 00:00:04 /usr/libexec/gvfs-udisks2-volume-monitor
sachi 2741 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-afc-volume-monitor
sachi 2746 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
sachi 2750 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor
sachi 2754 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-goa-volume-monitor
sachi 2757 1 0 Jun26 ? 00:00:00 /usr/libexec/goa-daemon
sachi 2764 1 0 Jun26 ? 00:00:43 /usr/libexec/goa-identity-service
sachi 2766 2380 0 Jun26 ? 00:01:31 /usr/bin/gnome-shell
sachi 2773 1 0 Jun26 ? 00:00:00 /usr/libexec/dconf-service
sachi 2781 1 0 Jun26 ? 00:00:00 /usr/libexec/gsd-printer
sachi 2798 1 0 Jun26 ? 00:00:00 /usr/bin/ibus-daemon --replace --xim --panel disable
sachi 2806 2798 0 Jun26 ? 00:00:00 /usr/libexec/ibus-dconf
sachi 2808 1 0 Jun26 ? 00:00:00 /usr/libexec/ibus-x11 --kill-daemon
sachi 2816 1 0 Jun26 ? 00:00:00 /usr/libexec/gnome-shell-calendar-server
sachi 2820 1 0 Jun26 ? 00:00:06 /usr/libexec/mission-control-5
sachi 2832 1 0 Jun26 ? 00:00:00 /usr/libexec/evolution-source-registry
sachi 2840 2798 0 Jun26 ? 00:00:00 /usr/libexec/ibus-engine-simple
sachi 2942 1 0 Jun26 ? 00:00:00 /usr/libexec/evolution-addressbook-factory
sachi 2947 1 0 Jun26 ? 00:00:01 /usr/libexec/gconfd-2
sachi 2954 1 0 Jun26 ? 00:00:00 /usr/libexec/tracker-store
sachi 2970 1 0 Jun26 ? 00:00:00 /usr/libexec/evolution-calendar-factory
sachi 3010 1 0 Jun26 ? 00:00:00 /usr/libexec/gnome-session-failed --allow-logout
sachi 3014 2380 0 Jun26 ? 00:00:00 /usr/bin/seapplet
sachi 3029 2380 0 Jun26 ? 00:00:00 abrt-applet
root 13024 948 0 09:11 ? 00:00:00 sshd: sachi [priv]
sachi 13033 13024 0 09:11 ? 00:00:00 sshd: sachi@pts/0
sachi 13039 13033 0 09:11 pts/0 00:00:00 -bash
sachi 13355 13039 0 09:13 pts/0 00:00:00 psql
root 13358 948 0 09:13 ? 00:00:00 sshd: sachi [priv]
sachi 13363 13358 0 09:13 ? 00:00:00 sshd: sachi@pts/1
sachi 13370 13363 0 09:13 pts/1 00:00:00 -bash
sachi 21534 13370 0 10:02 pts/1 00:00:00 ps -ef
sachi 21535 13370 0 10:02 pts/1 00:00:00 grep --color=auto sachi
[sachi@localhost ~]$ ps -ef |grep sachi| grep -v idle|grep -v grep
sachi 2380 2353 0 Jun26 ? 00:00:06 gnome-session --session gnome-classic
sachi 2388 1 0 Jun26 ? 00:00:00 dbus-launch --sh-syntax --exit-with-session
sachi 2396 1 0 Jun26 ? 00:00:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
sachi 2484 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfsd
sachi 2551 1 0 Jun26 ? 00:00:00 /usr/libexec//gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
sachi 2554 2380 0 Jun26 ? 00:00:02 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "env GNOME_SHELL_SESSION_MODE=classic gnome-session --session gnome-classic"
sachi 2595 1 0 Jun26 ? 00:00:00 /usr/libexec/at-spi-bus-launcher
sachi 2599 2595 0 Jun26 ? 00:00:00 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
sachi 2603 1 0 Jun26 ? 00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
sachi 2611 2380 0 Jun26 ? 00:00:22 /usr/libexec/gnome-settings-daemon
sachi 2627 1 0 Jun26 ? 00:00:02 /usr/bin/pulseaudio --start
sachi 2632 1 0 Jun26 ? 00:00:00 /usr/bin/gnome-keyring-daemon --start --components=ssh
sachi 2726 1 0 Jun26 ? 00:00:04 /usr/libexec/gvfs-udisks2-volume-monitor
sachi 2741 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-afc-volume-monitor
sachi 2746 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
sachi 2750 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor
sachi 2754 1 0 Jun26 ? 00:00:00 /usr/libexec/gvfs-goa-volume-monitor
sachi 2757 1 0 Jun26 ? 00:00:00 /usr/libexec/goa-daemon
sachi 2764 1 0 Jun26 ? 00:00:43 /usr/libexec/goa-identity-service
sachi 2766 2380 0 Jun26 ? 00:01:31 /usr/bin/gnome-shell
sachi 2773 1 0 Jun26 ? 00:00:00 /usr/libexec/dconf-service
sachi 2781 1 0 Jun26 ? 00:00:00 /usr/libexec/gsd-printer
sachi 2798 1 0 Jun26 ? 00:00:00 /usr/bin/ibus-daemon --replace --xim --panel disable
sachi 2806 2798 0 Jun26 ? 00:00:00 /usr/libexec/ibus-dconf
sachi 2808 1 0 Jun26 ? 00:00:00 /usr/libexec/ibus-x11 --kill-daemon
sachi 2816 1 0 Jun26 ? 00:00:00 /usr/libexec/gnome-shell-calendar-server
sachi 2820 1 0 Jun26 ? 00:00:06 /usr/libexec/mission-control-5
sachi 2832 1 0 Jun26 ? 00:00:00 /usr/libexec/evolution-source-registry
sachi 2840 2798 0 Jun26 ? 00:00:00 /usr/libexec/ibus-engine-simple
sachi 2942 1 0 Jun26 ? 00:00:00 /usr/libexec/evolution-addressbook-factory
sachi 2947 1 0 Jun26 ? 00:00:01 /usr/libexec/gconfd-2
sachi 2954 1 0 Jun26 ? 00:00:00 /usr/libexec/tracker-store
sachi 2970 1 0 Jun26 ? 00:00:00 /usr/libexec/evolution-calendar-factory
sachi 3010 1 0 Jun26 ? 00:00:00 /usr/libexec/gnome-session-failed --allow-logout
sachi 3014 2380 0 Jun26 ? 00:00:00 /usr/bin/seapplet
sachi 3029 2380 0 Jun26 ? 00:00:00 abrt-applet
root 13024 948 0 09:11 ? 00:00:00 sshd: sachi [priv]
sachi 13033 13024 0 09:11 ? 00:00:00 sshd: sachi@pts/0
sachi 13039 13033 0 09:11 pts/0 00:00:00 -bash
sachi 13355 13039 0 09:13 pts/0 00:00:00 psql
root 13358 948 0 09:13 ? 00:00:00 sshd: sachi [priv]
sachi 13363 13358 0 09:13 ? 00:00:00 sshd: sachi@pts/1
sachi 13370 13363 0 09:13 pts/1 00:00:00 -bash
sachi 21571 13370 0 10:02 pts/1 00:00:00 ps -ef
[sachi@localhost ~]$