
Terminal - Commands using ps - 185 results
ps -C program_name || { program_name & }
This is sample output - yours may be different.
This is sample output - yours may be different.
psg() { ps aux | grep "[${1[1]}]${1[2,-1]}"; }
This is sample output - yours may be different.
`--> ps? urxvt
root 5850 0.0 0.0 74404 3812 ? Ss 20:21 0:00 urxvt
root 25961 0.0 0.0 74388 3732 ? Ss 20:34 0:00 urxvt
alias ps?='psg' for maximum hawtness. Works in bash or zsh.
ps -ef | awk '/process-name/ && !/awk/ {print}'
This is sample output - yours may be different.
$ ps -ef | awk '/mingetty/ && !/awk/ {print}'
root 4976 1 0 Jul01 tty1 00:00:00 /sbin/mingetty --noclear tty1
root 4977 1 0 Jul01 tty2 00:00:00 /sbin/mingetty tty2
root 4978 1 0 Jul01 tty3 00:00:00 /sbin/mingetty tty3
root 4979 1 0 Jul01 tty4 00:00:00 /sbin/mingetty tty4
root 4980 1 0 Jul01 tty5 00:00:00 /sbin/mingetty tty5
root 4981 1 0 Jul01 tty6 00:00:00 /sbin/mingetty tty6
This does the same thing as many of the 'grep' based alternatives but allows a more finite control over the output. For example if you only wanted the process ID you could change the command:
ps -ef | awk '/mingetty/ && !/awk/ {print $2}'
If you wanted to kill the returned PID's:
ps -ef | awk '/mingetty/ && !/awk/ {print $2}' | xargs -i kill {}
command ps -Hacl -F S -A f
This is sample output - yours may be different.
F S UID PID PPID CLS PRI ADDR SZ WCHAN RSS PSR STIME TTY TIME CMD
5 S root 30780 1 TS 29 - 1075 - 1044 3 Aug18 ? 0:19 /usr/sbin/sshd
4 S root 17479 30780 TS 27 - 1719 - 2156 0 00:13 ? 0:00 \_ sshd: graves [priv]
5 S graves 17482 17479 TS 29 - 1775 - 1676 0 00:13 ? 0:00 \_ sshd: graves@pts/0
0 S graves 17483 17482 TS 29 - 864 wait 2280 0 00:13 pts/0 0:00 \_ -bash
0 R graves 17142 17483 TS 27 - 640 - 820 3 02:46 pts/0 0:00 \_ ps -Hacl -F S -A f
5 S root 30816 1 TS 26 - 8484 - 20872 3 Aug18 ? 14:31 /dh/apache2/apache2-etherape/apache2-etherape-httpd -DModSSL -d /dh/apache2/apache2-etherape
5 S dhapache 8429 30816 TS 29 - 8404 - 14788 1 Aug18 ? 0:00 \_ /dh/apache2/apache2-etherape/fcgi-pm -DModSSL -d /dh/apache2/apache2-etherape
5 S dhapache 8442 30816 TS 29 - 8484 - 15004 2 Aug18 ? 0:47 \_ /dh/apache2/apache2-etherape/apache2-etherape-httpd -DModSSL -d /dh/apache2/apache2-etherape
4 S htacces 5374 8442 TS 27 - 4961 376052 8680 0 01:51 ? 0:03 | \_ php5.cgi
4 S htacces 5375 8442 TS 28 - 4957 390250 8648 0 01:51 ? 0:02 | \_ php5.cgi
0 S root 8466 30816 TS 25 - 790 sinitt 1156 0 Aug18 ? 0:00 \_ /dh/passenger/ext/apache2/ApplicationPoolServerExecutable 0 /usr/bin/ruby
I don't truly enjoy many commands more than this one, which I alias to be ps1.. Cool to be able to see the heirarchy and makes it clearer what need to be killed, and whats really going on.
ps aux | grep [c]ommandname
This is sample output - yours may be different.
This is sample output - yours may be different.
ion@atomos:~$ ps -C ps
PID TTY TIME CMD
14524 pts/1 00:00:00 ps
ion@atomos:~$ ps -fC ps
UID PID PPID C STIME TTY TIME CMD
ion 14544 13940 0 11:23 pts/1 00:00:00 ps -fC ps
preferred way to query ps for a specific process name (not supported with all flavors of ps, but will work on just about any linux afaik)
ps aux | grep [p]rocess-name
This is sample output - yours may be different.
> ps aux | grep [m]ingetty
root 2381 0.0 0.0 7152 824 tty1 Ss+ Aug11 0:00 /sbin/mingetty --noclear tty1
root 2382 0.0 0.0 7152 828 tty2 Ss+ Aug11 0:00 /sbin/mingetty tty2
root 2383 0.0 0.0 7156 828 tty3 Ss+ Aug11 0:00 /sbin/mingetty tty3
root 2384 0.0 0.0 7156 828 tty4 Ss+ Aug11 0:00 /sbin/mingetty tty4
root 2385 0.0 0.0 7156 832 tty5 Ss+ Aug11 0:00 /sbin/mingetty tty5
root 2410 0.0 0.0 7156 832 tty6 Ss+ Aug11 0:00 /sbin/mingetty tty6
As an alternative to using an additional grep -v grep you can use a simple regular expression in the search pattern (first letter is something out of the single letter list ;-)) to drop the grep command itself.
ps aux | grep process-name | grep -v "grep"
This is sample output - yours may be different.
This is sample output - yours may be different.
ps -o comm= -p $(ps -o ppid= -p $$)
This is sample output - yours may be different.
Get the name of the parent command. This might be helpful, if you need to react on that information. E. g. a script called directly via ssh has got sshd as parent, manually invoked the parent process will probably be bash
ps -o rss -C httpd | tail -n +2 | (sed 's/^/x+=/'; echo x) | bc
This is sample output - yours may be different.
Display the amount of memory used by all the httpd processes. Great in case you are being Slashdoted!
ps -u $USER |grep $1 | awk '{ print $1}'| xargs kill
This is sample output - yours may be different.
Well this can come handy , when you don't feel like playing with pid rather if you know
the process name say "firefox",it would kill it.The script given below would kill the process with its name given as first parameter , though not robust enough to notify that process doesn't exist , well if you know what you are doing that's wouldn't be a problem.:)
----
killhim.sh
----
#!/bin/bash
ps -u $USER |grep $1 | awk '{ print $1}'| xargs kill
----
ps ax -o "%p %U %u %x %c %n"
This is sample output - yours may be different.
27281 1000 1000 00:00:00 kio_file 0
27282 1000 1000 00:00:00 ruby 0
27301 1000 1000 00:00:00 kio_uiserver 0
27355 1000 1000 00:00:00 kdesud 0
28425 1000 1000 00:00:00 bash 0
30166 1000 1000 00:00:17 htop 0
32256 1000 1000 00:00:00 kio_pop3 0
32359 1000 1000 00:00:00 man 0
32370 1000 1000 00:00:00 pager 0
ps command gives the possibility to display information with custom formatting with the -o options followed by the format specifier list.
This is sample output - yours may be different.
If you want a visual representation of the parent/child relationships between processes, this is one easy way to do it. It's useful in debugging collections of shell scripts, because it provides something like a call traceback.
When a shell script breaks, just remember "awwfux".
ps aux | grep -v `whoami`
This is sample output - yours may be different.
ps -eo user,pcpu,pmem | tail -n +2 | awk '{num[$1]++; cpu[$1] += $2; mem[$1] += $3} END{printf("NPROC\tUSER\tCPU\tMEM\n"); for (user in cpu) printf("%d\t%s\t%.2f%\t%.2f%\n",num[user], user, cpu[user], mem[user]) }'
This is sample output - yours may be different.
NPROC USER CPU MEM
16 web2 10.80% 0.00%
1 rpc 0.00% 0.00%
44 web 18.30% 1.70%
9 patrol 0.00% 0.00%
11 wikimoe 0.00% 1.50%
11 gipce 0.00% 0.40%
3 68 0.00% 0.00%
1 dbus 0.00% 0.00%
1 rpcuser 0.00% 0.00%
1 named 0.30% 0.00%
11 wikiprod 0.20%
2 appli 0.00% 0.00%
1 smmsp 0.00% 0.00%
2 avahi 0.00% 0.00%
10 webdba 0.00% 0.00%
1 xfs 0.00% 0.00%
1 ntp 0.00% 0.00%
281 root 2.30% 8.10%
It's like `prstat -t` under Solaris
ps auxf | grep httpd | grep -v grep | grep -v defunct | awk '{sum=sum+$6}; END {print sum/1024}'
This is sample output - yours may be different.
This is sample output - yours may be different.
ps aux | sort +2n | tail -20
This is sample output - yours may be different.
This command will show the 20 processes using the most CPU time (hungriest at the bottom).
You can see the 20 most memory intensive processes (hungriest at the bottom) by running:
ps aux | sort +3n | tail -20
Or, run both:
echo "CPU:" && ps aux | sort +2n | tail -20 && echo "Memory:" && ps aux | sort +3n | tail -20
[[ $(COLUMNS=200 ps faux | awk '/grep/ {next} /ssh -N -R 4444/ {i++} END {print i}') ]] || nohup ssh -N -R 4444:localhost:22 user@relay &
This is sample output - yours may be different.
I find it ugly & sexy at the same time isn't it ?
ps ax | grep <processname> | grep -v grep | awk '{print $1}' | sudo xargs kill -9
This is sample output - yours may be different.
ps aux | grep 'httpd ' | awk {'print $2'} | xargs kill -9
This is sample output - yours may be different.
ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed "/^ 0.0 /d"
This is sample output - yours may be different.
ps -o %mem= -C firefox-bin | sed -s 's/\..*/%/'
This is sample output - yours may be different.