I basically have a custom service i am running.... I want puppet to run a command if the process doesn''t show up in ps - aux What is happening is it runs the command no matter what. here is my exec exec { "$rule-$interface-svscan": command => "/usr/sbin/daemon -f /bin/sh -c \"/usr/ local/bin/svscan /data/service\"", unless => "/bin/ps -aux |/usr/bin/grep ''/data/ service''", } -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Jul 21, 11:28 am, Panaman <pana...@gmail.com> wrote:> I basically have a custom service i am running.... > I want puppet to run a command if the process doesn''t show up in ps - > aux > > What is happening is it runs the command no matter what. > here is my exec > > exec { "$rule-$interface-svscan": > command => "/usr/sbin/daemon -f /bin/sh -c \"/usr/ > local/bin/svscan /data/service\"", > unless => "/bin/ps -aux |/usr/bin/grep ''/data/ > service''", > > > > }- Hide quoted text - > > - Show quoted text --- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Oops: On Jul 22, 7:51 am, jcbollinger <John.Bollin...@stJude.org> wrote:> On Jul 21, 11:28 am, Panaman <pana...@gmail.com> wrote: > > > > > I basically have a custom service i am running.... > > I want puppet to run a command if the process doesn''t show up in ps - > > aux > > > What is happening is it runs the command no matter what. > > here is my exec > > > exec { "$rule-$interface-svscan": > > command => "/usr/sbin/daemon -f /bin/sh -c \"/usr/ > > local/bin/svscan /data/service\"", > > unless => "/bin/ps -aux |/usr/bin/grep ''/data/ > > service''", > > > }I meant to say: start by checking your command paths. In particular, grep is in /bin on my Cent 5 boxes, and not in /usr/bin. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
I believe your issue is that your grep command will ALWAYS return 0 since it will see it''s one process in the process list. You must add a second grep to ignore it. Try the following: unless => "/bin/ps -aux |/usr/bin/grep ''/data/service'' | grep -v grep" -John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/24/2011 01:40 AM, John Martin wrote:> You must add > a second grep to ignore it.the idiom is to use a trivial character class: unless => "/bin/ps -aux | /usr/bin/grep ''/[d]ata/service''", -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Ian Mortimer
2011-Jul-25 04:50 UTC
Re: [Puppet Users] Re: exec onlyif not working properly
On Sun, 2011-07-24 at 02:03 -0400, vagn scott wrote:> the idiom is to use a trivial character class: > > unless => "/bin/ps -aux | /usr/bin/grep ''/[d]ata/service''",Or use pgrep which never matches itself: /usr/bin/pgrep -f ''/data/service'' -- Ian -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.