
Terminal - Commands using ps - 184 results
ps -e -m -o user,pid,args,%mem,rss | grep Chrome | perl -ne 'print "$1\n" if / (\d+)$/' | ( x=0;while read line; do (( x += $line )); done; echo $((x/1024)) );
This is sample output - yours may be different.
How much memory is chrome sucking?
renice -20 -g 2874 (2784 found with ps -Aj)
This is sample output - yours may be different.
ps aux | grep [process] | awk '{print $2}' | xargs -I % ls /proc/%/fd | wc -l
This is sample output - yours may be different.
ps aux | grep <process> | grep -v grep | awk '{print $2}' | xargs -i -t kill -9 {}
This is sample output - yours may be different.
ps auxw | grep sbin/apache | awk '{print"-p " $2}' | xargs strace -f
This is sample output - yours may be different.
This version also attaches to new processes forked by the parent apache process. That way you can trace all current and *future* apache processes.
ps -u user_name_here | grep process_name_here | wc -l
This is sample output - yours may be different.
ps -xaw -o state,ppid | grep Z | grep -v PID | awk '{ print $2 }' | xargs kill -9
This is sample output - yours may be different.
Did some research and found the previous command wrong, we don't kill a zombie but its parent. Just made some modifcation to khashmeshab's command.
This is sample output - yours may be different.
user@ubuntu:~$ ps axu | grep [a]pache2
root 9399 0.0 0.1 105628 7588 ? SNs 11:55 0:01 /usr/sbin/apache2 -k start
www-data 9401 0.0 0.1 105716 5576 ? SN 11:55 0:00 /usr/sbin/apache2 -k start
www-data 9402 0.0 0.1 105716 5572 ? SN 11:55 0:00 /usr/sbin/apache2 -k start
www-data 9403 0.0 0.1 105668 5028 ? SN 11:55 0:00 /usr/sbin/apache2 -k start
www-data 9404 0.0 0.1 105716 5576 ? SN 11:55 0:00 /usr/sbin/apache2 -k start
www-data 9405 0.0 0.1 105652 4788 ? SN 11:55 0:00 /usr/sbin/apache2 -k start
www-data 15581 0.0 0.1 105652 4788 ? SN 12:04 0:00 /usr/sbin/apache2 -k start
www-data 15582 0.0 0.1 105652 4788 ? SN 12:04 0:00 /usr/sbin/apache2 -k start
www-data 15583 0.0 0.1 105652 4788 ? SN 12:04 0:00 /usr/sbin/apache2 -k start
Trick to avoid the form:
grep process | grep - v grep
while true; do date; ps auxf | awk '{if($8=="D") print $0;}'; sleep 1; done
This is sample output - yours may be different.
ps -ef | awk -v OFS="\n" '{ for (i=8;i<=NF;i++) line = (line ? line FS : "") $i; print NR ":", $1, $2, $7, line, ""; line = "" }'
This is sample output - yours may be different.
1:
root
3410
00:00:00
gpm -m /dev/input/mice -t exps2
2:
root
3424
00:00:00
crond
3:
root
3488
00:00:00
/usr/sbin/atd
ps -eo size,pid,user,command --sort -size |awk '{hr[1024**2]="GB";hr[1024]="MB";for (x=1024**3; x>=1024; x/=1024){if ($1>=x){printf ("%-6.2f %s ", $1/x, hr[x]);break}}}{printf ("%-6s %-10s ", $2, $3)}{for (x=4;x<=NF;x++){printf ("%s ",$x)} print ("\n")}'
This is sample output - yours may be different.
1.49 GB 6457 1001 /opt/google/chrome/chrome --type=renderer --lang=en-US --force-fieldtest=CacheListSize/CacheListSize_14/ConnCountImpact/conn_count_6/ConnnectBackupJobs/ConnectBackupJobsEnabled/DnsImpact/default_enabled_prefetch/DnsParallelism/parallel_default/GlobalSdch/global_enable_sdch/IdleSktToImpact/idle_timeout_10/Instant/HiddenExperimentB/Prefetch/ContentPrefetchPrerender2/PrerenderFromOmnibox/OmniboxPrerenderEnabled/PrerenderFromOmniboxHeuristic/ExactFullAlgorithm/ProxyConnectionImpact/proxy_connections_32/SpdyCwnd/cwnd10/SpdyImpact/npn_with_spdy/WarmSocketImpact/warmest_socket/ --extension-process --enable-print-preview --channel=6390.0xb9b71c60.593461523
630.18 MB 2488 1001 /usr/lib/thunderbird-3.1.8/thunderbird-bin
501.08 MB 3426 1001 /usr/lib/firefox-3.6.3/firefox-bin
272.55 MB 11897 1001 /usr/lib/chromium-browser/chromium-browser
Finding high memory usage report in human readable format.
ps aux --sort -rss | head
This is sample output - yours may be different.
for i in $(ps -eo pid|grep -v PID);do echo ""; echo -n "==$i== ";awk '/^read|^write/{ORS=" "; print}' /proc/$i/io 2>/dev/null; echo -n " ==$i=="; done|sort -nrk5|awk '{printf "%s\n%s %s\n%s %s\n%s\n\n",$1,$2,$3,$4,$5,$6}'
This is sample output - yours may be different.
export proc=chrome && ps aux | grep $proc | grep -v grep |awk '{print $2}'
This is sample output - yours may be different.
ps axo %mem,pid,euser,cmd | sort -nr | head -n 10
This is sample output - yours may be different.
11.5 1957 lainme firefox http://twitter.com/keyi_bu/status/256446157193093120/photo/1
3.4 1813 lainme /usr/bin/gnome-shell
3.3 1867 lainme /usr/bin/python2 /usr/bin/hotot-gtk3
2.6 5183 lainme conky
1.5 1645 root /usr/bin/Xorg :0 -br -verbose -auth /var/run/gdm/auth-for-gdm-3aSYDI/database -nolisten tcp vt8
1.0 1854 lainme pidgin
1.0 18439 lainme fcitx
0.9 1998 lainme /usr/lib/firefox/plugin-container /usr/lib/mozilla/plugins/libflashplayer.so -greomni /usr/lib/firefox/omni.ja 1957 plugin
0.4 1821 lainme nm-applet
0.4 1785 lainme /usr/lib/gnome-settings-daemon/gnome-settings-daemon
ps wwwwuax|awk '/command/ { printf("kill -9 %s\n",$2) }'|/bin/sh
This is sample output - yours may be different.
Okay, commands like this are a bit of a personal peeve. awk(1) operates on a /pattern/ {action} paradigm and yet I see people leave out the /pattern/ portion of an awk command all the time, opting to use grep or sed instead. You'll save yourself some typing and time if you include the /pattern/ with your {action}.
ps -fu $USER | awk {'print $2'} | xargs kill [-9]
This is sample output - yours may be different.
ps auxww | grep application | grep processtobekilled | gawk '{print $2}' | grep -v grep | xargs kill -9
This is sample output - yours may be different.
You can also use gawk:
ps auxww | gawk '/application/' | gawk '/processtobekilled/' | gawk '{print $2}' | grep -v grep | xargs kill -9
ps aux | awk '{if ($8 ~ "D") print $0}'
This is sample output - yours may be different.
Lots of fun to run on nfs clients when the server or network connection is having issues
kill -9 -$(ps x -o "%c %r" | awk '/svscan/{print $2}')
This is sample output - yours may be different.
Daemontools[1] won't always properly reap it's children. Sometimes when you need to kill the main svscan process, you want to also clean up all of it's children. The way to do that is to send a signal to the entire process group. It is a bit tricky
[1] http://cr.yp.to/daemontools.html
ps -e h -o pid --sort -pcpu | head -10 | vzpid -
This is sample output - yours may be different.
Pid VEID Name
2860 1014040 ruby
5647 0 htop
5143 1013101 mysqld
6095 1013151 mysqld
2922 1014040 ruby
3043 0 ruby
4252 1014045 freshclam
3488 1014045 amavisd-new
1 0 init
9 0 events/0
This command will list the PID, VEID, and Name of the 10 highest cpu using processes on a openvz host. You must have vzpid installed.
slow () { [ -n $1 ] && while ps -p $1 >/dev/null ; do kill -STOP $1; sleep 1; kill -CONT $1; sleep 1; done & }
This is sample output - yours may be different.
bash> cp /tmp/BIG /tmp/2 & slow $!
[1] 26494
[2] 26495
Some IO intensive process make the system unresponsive. This function periodically starts/stops a process, which hopefully releases some resources for other activities.
This function is useful when ionice is not available
ps afx | grep defunct -B 1 | grep -Eo "[0-9]{3,}" | xargs kill -9
This is sample output - yours may be different.
defunct processes (zombies) usually have to be killed by killing their parent processes. this command retrieves such zombies and their immediate parents and kills all of the matching processes.
This is sample output - yours may be different.
When you 'ps|grep' for a given process, it turns out that grep itself appears as a valid line since it contains the RE/name you are looking for. To avoid grep from showing itself, simply insert some wildcard into process' name.
_p(){ ps ax |grep $1 |sed '/grep.'"$1"'/d' |while read a;do printf ${a%% *}' ';printf "${a#* }" >&2;printf '\n';done;}
This is sample output - yours may be different.
proc lister
usage: p
proc killer
usage: p patt [signal]
uses only ps, grep, sed, printf and kill
no need for pgrep/pkill (not part of early UNIX)
_p(){
ps ax \
|grep $1 \
|sed '
/grep.'"$1"'/d' \
|while read a;do
printf ${a%% *}' ';
printf "${a#* }" >&2;
printf '\n';
done;
}
p(){
case $# in
0)
ps ax |grep .|less -iE;
;;
1)
_p $1;
;;
[23])
_p $1 2>/dev/null \
|sed '/'"$2"'/!d;
s,.*,kill -'"${3-15}"' &,'|sh -v
;;
esac;
}
alas, can't get this under 255 chars.
flatcap?