3 ms·
Their first example is bad: ps aux | grep nginx | grep root | grep -v grep can be done instead (from memory, not at a Linux machine ATM): ps -u root
by foobarqux 9mo ago
Their first example is bad:
ps aux | grep nginx | grep root | grep -v grep
can be done instead (from memory, not at a Linux machine ATM):
ps -u root -C nginx
which is arguably better than their solution:
psc 'process.name == "nginx" && process.user == "root"'
- xorcist 9mo agoThe commands in their example are not equivalent. The ps | grep thing searches the full command line including argument while ps -C (and, presumably, the psc thing) just returns the process name. Should you for some reason want to do the former, this is easiest done using: pgrep -u root -f nginx which exists on almost all platforms, with the notable exception of AIX. Their other slightly convoluted example is: psc 'socket.state == established && socket.dstPort == uint(443)' which is much more succinct with: lsof -i :443 -s TCP:ESTABLISHED
- wang_li 9mo agoMany new tools appear because people don't know how to use the existing tools or they think the existing tool is too complicated. In time the new tool becomes just as, or more, complicated than the old tool. Because there is a reason the old tool is complicated, which is that the problem requires complexity.
- dundarious 9mo agoIt has process.cmdline as well as .name
- mxey 9mo ago“ss” also has filters, no need for grep ss -o state established '( dport = :ssh or sport = :ssh )'