I am just starting to learn monit. On its man page I found this:

The behavior of Monit is controlled by command-line options and a run control file, ~/.monitrc, the syntax of which we describe in a later section. Command-line options override .monitrc declarations.

And when I created my .monitrc file with the following content and test it, it showed errors and I changed it and it is fine now:

➜  brt_client git:(master) ✗ monit -t                    
/home/jgu/.monitrc:2: Warning: Program does not exist: 'echo'
➜  brt_client git:(master) ✗ vim ~/.monitrc              
➜  brt_client git:(master) ✗ vim ~/.monitrc
➜  brt_client git:(master) ✗ monit -t      
➜  brt_client git:(master) ✗

but when I do service monit restart, I got this:

➜  brt_client git:(master) ✗ service monit restart
 * Stopping daemon monitor monit                                                                                                                                                                      [ OK ] 
 * Starting daemon monitor monit                                                                                                                                                                             empty config, please edit /etc/monit/monitrc.

So I checked the code in /etc/init.d/monit and found this:

monit_check_config () {
  # Check for emtpy config.
  if [ "`grep -s -v \"^#\" $CONFIG`" = "" ]
    echo "empty config, please edit $CONFIG."
    exit 0

So if I am not wrong, this program does not take -c or other flags. And I checked the log in /var/log/monit.log, it did not show that I restarted it. Of course, according to the script, it just exited with 0(why it is exiting with 0?).

So I checked the file, turns out I do not have the access to read /etc/monit/monitrc. So get sudo privilege for moinit and tried again. It is fine.

So now comes the actual question:

I did not find anything related to "~/.monitrc" in /etc/monit/monitrc, like "include ~/.monitrc", only include the directory in conf.d, how does monit know to load .monitrc in home directory? (By magic?)

And let's say I logged out and my college login to my computer with his account, does that mean my configuration will not work for him at all?

But that monit reload should have happened right? (if it does not get reloaded, then my ~/.monitrc should still be functioning)


The .*rc files in user home directory are usually meant for providing some user-specific defaults while system-level defaults are usually given in a *rc file under /etc for the same application.

man monit ought to tell you this:

~/.monitrc Default run control file

/etc/monitrc If the control file is not found in the default location and /etc contains a monitrc file, this file will be used instead.

./monitrc If the control file is not found in either of the previous two locations, and the current working directory contains a monitrc file, this file is used instead.

However, since you are telling that in your case the default run control file is /etc/monit/monitrc instead of /etc/monitrc there might also be other deviations from what the developers have written in the man page (or it might be that the man page is out-of-date, or your question has incorrect path for that file).

In the context of running monit as a service the above would mean that it is defaulting to .monitrc file in the home dir of the user the service is being run, and if it doesn't find such file it'll use the default one under /etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.