Linux Commands

Geekish One Liner Linux Command Sequences

—————————————————————–

#kill processes in bulk
ps aux | grep -i XXXX | cut -d ” ” -f3 | xargs kill

pgrep, pkill

—————————————————————–

# Find all python processes which are not daemons(PPID !=1) and have been running for more than two days

ssh username@host  ps -eo etime,ppid,pid,command | grep -i python | awk ‘(($2 !~ /^1$/) && ($1 ~ /^.?-.?.?:.?.?:.?.?$/) && ($1 > 2))  {print $0}’

—————————————————————–

# walk through the specified directory for all files that match a particular pattern. print filename, followed by matched line.
find __PATH__  -type f -exec grep -Hi __PATTERN__ ‘{}’ \;

—————————————————————–

find . -print0 | xargs -0 touch

—————————————————————–

ps -eo etime,ppid,pid,command | grep -i python | awk ‘{if ($2 != 1) print $0}’  | awk ‘{if ($1 > 2) print $0}’

—————————————————————–

# Find all python processes which are not daemons(PPID !=1) and have been running for more than two days
for hosts in $(_LIST_OF_HOSTS_); do echo $hosts; ssh release@$hosts ps -eo etime,ppid,pid,command | grep -i python | awk ‘(($2 !~ /^1$/) && ($1 ~ /^.?-.?.?:.?.?:.?.?$/) && ($1 > 2))  {print $0}’ ; done

—————————————————————–

#find python tracebacks in /cv/logs for last 24 hours, sort, uniq.
find  __PATH_  -type f -mtime -1  | xargs grep -e “Traceback”  | sort -t: -u +7 -8 $1 |  sort -t: -u  +6 -7  | sort -t: +0 -1 | awk ‘BEGIN{ ORS = “\n\n” } { print $0 }’

—————————————————————–

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: