Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
1  
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
add comment

1 Answer

Your command line could be:

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

where:

  • 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
add comment

Your Answer

 
discard

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.