Pkill has issues with capistrano, because the pkill command is always inside a capistrano command, thereby matching and killing itself.
pkill free solution
task :foo do kill_processes_matching "MaintenanceDaemon" end def kill_processes_matching(name) run "ps -ef | grep #{name} | grep -v grep | awk '{print $2}' | xargs kill || echo 'no process with name #{name} found'" end
Thanks! That was awesome. I was never able to figure out why “sh -c ‘pkill …’ ” didnt work. It worked with sudo though i really didnt want the kill to be run with sudo.
I ran into this. However, in my case, I was matching the end of the command line used, so adding a $ to the end of my pattern caused it to match the one I wanted an not the capistrano spawned process.