Glam Prestige Journal

Bright entertainment trends with youth appeal.

I would like to know what is this statement doing exactly, especially the awk part.

ps aux | grep 'sidekiq 5' | grep -v grep | awk '{ print $2; }' | xargs kill -${2:-'TERM'}

I know the entire pipeline is supposed to kill sidekiq processes.

3

1 Answer

  • ps aux lists all processes.
  • grep 'sidekiq 5' only displays those lines from the list that contain the string "sidekiq 5".
  • grep -v grep removes those lines that contain the string "grep". This is done so that the grep process from the previous pipeline stage is filtered out.
  • awk '{ print $2; }' prints the second field of each line. This field happens to be the process ID from the ps aux output.
  • xargs kill -${2:-'TERM'} takes the process IDs from the selected sidekiq processes and feeds them as arguments to a kill command. The signal is either $2 or, if $2 is not defined, SIGTERM.
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy