Ask Your Question

kill process

asked 2015-11-24 07:44:02 -0500

pribal gravatar image

updated 2015-11-24 11:38:13 -0500

GregLarkin gravatar image

Kill with exec is not working.Can u help ?

exec { "restart_process":
    path => ['/usr/bin', '/sbin', '/bin', '/usr/sbin'],
    command => "ps -ef | grep nrpe | grep -v pts/1 | /bin/awk '{print \$2}' | xargs kill -9",
    provider => 'shell',
    subscribe => File["/root/Backup/deploy"],
    refreshonly => true,

This gives below error

Info: Computing checksum on file /root/Backup/deploy/
Info: /Stage[main]/Myfile/File[/root/Backup/deploy/]: Filebucketed /root/Backup/deploy/ to puppet with sum 136c6013774f5dfb84943718a70b36e0
Notice: /Stage[main]/Myfile/File[/root/Backup/deploy/]/content: content changed '{md5}136c6013774f5dfb84943718a70b36e0' to '{md5}c4fc9099405a108923ad18f7e2db13c8'
Info: /root/Backup/deploy: Scheduling refresh of Exec[restart_process]
Error: /Stage[main]/Myfile/Exec[restart_process]: Failed to call refresh: ps -ef | grep nrpe | grep -v pts/1 | /bin/awk '{print \$2 }' | xargs kill -9 returned  instead of one of [0]
Error: /Stage[main]/Myfile/Exec[restart_process]: ps -ef | grep nrpe | grep -v pts/1 | /bin/awk '{print \$2 }' | xargs kill -9 returned  instead of one of [0]
Notice: Finished catalog run in 1.56 seconds
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-11-24 11:42:56 -0500

GregLarkin gravatar image

Can you describe what you are trying to do here? Your exec resource is named "restart_process", but you are performing a "kill -9" on the process which will kill it permanently.

If you are trying to restart a process based on a file change, then you may want to try something like this:

file { '/root/Backup/deploy':
  ensure => file,
  source -or- content => 

service { 'nrpe':
  ensure    => running,
  enable    => true,
  subscribe => File['/root/Backup/deploy'],

This will refresh/reload your nrpe service when the /root/Backup/deploy file is changed. If you are trying to do something different, please post back here.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-11-24 07:44:02 -0500

Seen: 583 times

Last updated: Nov 24 '15