Search code examples
bashunixcommand-lineresquepid

Kill all pid files in a folder


I have a folder that is filled with .pid files. Each has the PID for a resque worker. How can I kill every PID in that folder from the command line?


Solution

  • According to the docs it says to use:

    ps -e -o pid,command | grep [r]esque-[0-9] | cut -d ' ' -f 1 | xargs -L1 kill -s QUIT
    

    Note: That looks them up by name instead of using the .pid files.

    Also, the QUIT signal will gracefully kill them. If you want to forcefully kill them use TERM instead.