4 ms·
I am guilty of using `ps|aux` for the sole purpose of answering this question: Is it (still) running ? edit: `ps aux|grep`, indeed. Silly me in the early hours
by johnchristopher 10y ago
I am guilty of using `ps|aux` for the sole purpose of answering this question: Is it (still) running ?
edit: `ps aux|grep`, indeed. Silly me in the early hours of a rest day :).
- rakoo 10y agoYou mean `ps aux | grep` which I am also guilty of using every time ? You might be interested in pgrep (http://linux.die.net/man/1/pgrep http://linux.die.net/man/1/pgrep) as well.
- semi-extrinsic 10y agoFor interactive use, I strongly recommend htop if you're still doing stuff like "ps aux | grep" and then "kill 84728". Htop is top on steroids: ncurses-based and very fast, has colors, threaded or flat process view, sorting by different criteria like cpu or ram use, searching for substring match in process name, interface to killing/signalling to selected process, etc. http://hisham.hm/htop/ http://hisham.hm/htop/
- johnchristopher 10y agoI am more a `killall <processname>` guy.
- koolba 10y ago> I am more a `killall <processname>` guy. I've made a note to name the executable for my next daemon "humans".
- Rondom 10y agoDon't do that on Solaris ;-)
- joosters 10y agoBeen there, done that :( See also the 'reboot' (or is it the 'poweroff' ?) command, which is much more direct than the Linux equivalent...
- amyjess 10y agoSometimes, I want something a little more murderous, so I tend to write this script on most systems I use: ps -ef | grep $1 | awk '{print "kill -9 " $2}' | sh Usually stored as /usr/local/bin/kll I've found it's very useful for killing specific Java programs without having to killall -9 java. (and, yeah, I should probably be using ps -efww instead of ps -ef, but old habits die hard... I've already got ps aliased to ps -ww for interactive use, so I should probably change this script...)
- imtringued 10y agoYou should try jps it's similar to ps but only lists java processes with their real names instead of just "java". It's included in pretty much every JDK.
- ozzmotik 10y agooh god i thought I was the only one
- voidz 10y ago'pkill' can do a bit more, it's the better alternative in my opinion.
- mxuribe 10y agoAgreed, htop is pretty awesome!
- amyjess 10y agoI discovered htop when regular top changed its default behavior to be nigh unusable. htop was recommended as an alternative, and while I've since learned how to configure top to go back to its old behavior [0], I've found that I just prefer htop now. [0] https://bbs.archlinux.org/viewtopic.php?id=189757 https://bbs.archlinux.org/viewtopic.php?id=189757
- emidln 10y agoFor just viewing system information, I usually prefer glances to htop, although it can't signal. It has a curses interface and also includes network traffic, docker containers, disk IO, and it's nicely pluggable for both output formats (it can dump to CSV at interval as a daemon or while you're running it interactively (or something like graphite/influxdb if you have those)) as well as collection mechanisms (you write some python).
- bluedino 10y ago>> I am guilty of using `ps|aux` What's wrong with doing that? I've been doing that for so long I don't know why I do it
- dozzie 10y agoBecause there's so many process selectors and formatters in ps from procps? ps -C procname ps -p pid ps -u username ps -t ttyname ps -f [-w [-w]] ps -o output-format
- glenjamin 10y agoI have this little bash function which I like to use to find out if a program is running, and to optionally kill it. Originally my goal was to keep it fitting inside a tweet, but adding helpful messaging just pushed it over. pgk () { [ -z "$*" ] && echo 'Usage: pgk <pattern>' && return 1; pgrep -fl $*; [ "$?" == "1" ] && echo 'No processes match' && return 1; echo 'Hit [Enter] to pkill, [Ctrl+C] to abort'; read && pkill -f $* }
- devonkim 10y agoModern Linuxes have pgrep to help avoid the inevitable "lol, the grep process I fired will match" issue that results in having to filter that out as well with yet another program.
- pacaro 10y agoGood to know, I always just `ps aux | grep [j]ava`
- smhenderson 10y agoYeah, I always felt having to type the extra bit was strange, like maybe grep could have a switch to say "don't find grep" but I guess having a switch for such a specific use case, grepping processes, is overkill. Anyway, it's just a reflex now to always: ps aux | grep <program> | grep -v grep
- amyjess 10y agoYou can also surround each character in the program's name with square brackets. ps -ef | grep [p][r][o][g][r][a][m]
- jpitz 10y agoYou only need surround one character.
- smhenderson 10y agoYes, I never knew that. But I saw it in another post and as the sibling post mentions it's enough to surround just the first character with the brackets... This is why I love HN, I learn stuff I never knew I wanted to know!
- nocman 10y agoOne problem with pgrep is it has no option to ignore case. Yes, I do sometimes have processes with camel-cased names which I may or may not remember exactly. So you: ps auwx | grep -i {lc-version-of-camel-cased-name}