Init Monit as non-root?

Hi All,

Question regarding Monit usage.

I’ve set up Monit using a config file that is owned by my Rails user.
Which works fine.

However, I’d rest easy on the weekends knowing that if the server is
rebooted then Monit will start up in the init processing and then
start all the Rails business. Problem is that since my Monit config
file is not owned by root the init process fails to start Monit. I’ve
tried some hacking about with the monit init.d script but this seems
rather ungraceful.

Is there a simple way to make this happen?

Or should I just relent and make the config file owned by root?

Thank You all,

Andy K.

Can you make your command be

su - -c “”?

That should work in one of the rc3.d (or higher run level) start


If I’m following you, the idea is to modify the Monit startup script
(namely “/etc/init.d/monit”) to use the ‘su …’ form.

However, the Monit script uses ‘start-stop-daemon’ command. Which has
a chuid option, and that actually works. But, it hangs on reboot.
While it does start Monit, and faithful employee Monit it turn starts
all it’s responsibilities, if one is watching the boot process the
init Monit process never returns.

… At this point I’m wondering if I should get into all the
details …

ah, what the hell, here is full disclosure…

I modified the monit init script to use chuid option which set user to
my Rails user. However, it didn’t write the Monit state file. Until
I changed permissions on that folder to allow Rails user. But then it
wouldn’t write the pid file, regardless of any permission changes I
made. At that point I wondered if I was taking the hard road.

While I’m not opposed to modifying the init script. My hope was to
find a clean way to run Monit without being (or having access to ) the
root user.