Linux Monit – Allow User to Run Specific Actions

linuxmonit

I have installed monit for many applications with the root user.
One of the applications is started with a non-root user account.

Unfortunately, when I
update my app, I also need to restart it. My update process uses the non-root user (I use capistrano to udpate my app)

Since Monit is checking this app and the update process is done with the non-root user. In order to restart the app, the non-root user kills the app and monit restarts it.

I would like to allow the non-root user to be allowed to only restart this specific app. This user shouldn't be aloud to run other monit related actions.

Is there a way to allow a user run a specific monit action, even if he is not the owner of the monitrc ?

Best Answer

Add an entry to /etc/sudoers...

%non-root-group ALL=NOPASSWD:/usr/bin/monit 

or

non-root-user ALL=NOPASSWD:/usr/bin/monit 

or

non-root-user ALL=NOPASSWD:/usr/bin/monit reload # to give a specific Monit command.