Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a new user of bash/cron, and I was given a task to create a cron which finds/kill/ and clears old puppet runs that were not successfully installed. The more help the better, but I am more or less looking for a starting point. Thanks in advance for your help!

share|improve this question
Are you looking for help making a cronjob, or help with finding a command to kill old puppet runs? – Michael Mrozek Feb 14 '12 at 14:37
help with finding a command to kill old puppet runs – Jeff Feb 16 '12 at 20:14

Your command line could be:

pidof puppet | sort -n | sed 's/^[0-9]* //' | while read p; do kill -9 $p; done


  • pidof gets the list of puppet processes running

  • sort -n, sorts in descending order

  • sed preserves the last puppet runs

  • the while loop gets the output from those commands and passes them to the kill command.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.