It is possible (using the "else if succeeded then ..." part:

        if does not exist then alert else if succeeded then exec 
"/usr/local/monit-scripts/ruby-daemon.sh push_notification stop"

Monit is however design to keep the process running, so if the process will be 
online on Monit start, the action won't be executed, as it must fail first in 
order to allow the fail->success transition.

It could be thus better to use "check program" with simple pgrep based script, 
more details about the "check program": 
http://www.mmonit.com/monit/documentation/monit.html#PROGRAM-STATUS-TESTING

Regards,
Martin 
 


> On 11 Nov 2014, at 14:59, Phil Townes <[email protected]> wrote:
> 
> Thanks Martin,
> I'm trying to achieve the opposite.
> If the process exists I need to stop it.
> 
> Is that possible?
> Thanks,
> Phil
> 
> On 11 November 2014 12:25, Martin Pala <[email protected] 
> <mailto:[email protected]>> wrote:
> Hi,
> 
> the correct syntax is:
> 
>         if DOES NOT exist then exec "/usr/local/monit-scripts/ruby-daemon.sh 
> push_notification stop"
> 
> Regards,
> Martin
> 
> 
> 
> > On 11 Nov 2014, at 13:03, Phil Townes <[email protected] 
> > <mailto:[email protected]>> wrote:
> >
> > Hi, I'm using monit 5.10 on Centos 6.4.
> > I'm trying to check that a process is NOT running on a server.
> > If the process is running I need to stop it.
> >
> > I've tried the following monit config:
> >
> > # Push Notification - SHOULD NOT BE RUNNING
> > check process Push_Notification_Service
> >     matching "push_notification.rb"
> >       if exist then exec "/usr/local/monit-scripts/ruby-daemon.sh 
> > push_notification stop"
> >
> > This generates a syntax error:
> > Starting monit: /etc/monit.d/must_not_be_running:3: syntax error 'exist'
> >
> > Is what I'm trying to do possible?
> >
> > For reference, here's the content of /usr/local/monit-scripts/ruby-daemon.sh
> >
> > #!/bin/bash
> > echo "Asking $1 for $2"
> > cd /var/www && RAILS_ENV=production bundle exec rake daemon:$1:$2
> > cd - > nul
> >
> > Thanks,
> > Phil
> >
> > --
> > To unsubscribe:
> > https://lists.nongnu.org/mailman/listinfo/monit-general 
> > <https://lists.nongnu.org/mailman/listinfo/monit-general>
> 
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general 
> <https://lists.nongnu.org/mailman/listinfo/monit-general>
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to