The work around is based on a software named
monit. Let’s see what monit do.
Monit is a small Open Source utility for managing and monitoring Unix systems. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.
- Download monit here for 64bits macOS https://mmonit.com/monit/dist/binary/5.21.0/monit-5.21.0-macos-x64.tar.gz
Extract the archive, you will get file like this:
Copy files into their locations
sudo cp -f bin/monit /usr/local/bin
sudo chmod a+x /usr/local/bin/monit
sudo cp -f conf/monitrc /usr/loca/etc
sudo cp -rf man/man1/monit.1 /usr/local/share/man/man1
- Test your installation
- Add the following lines into
check process Mail matching "/Applications/Mail.app/Contents/MacOS/Mail"
LaunchDaemon is the startup manager for macOS, and the startup items for LaunchDaemon can be started when system boot up before user login. It’s system level.
sudo vim /Library/LaunchDaemons/com.tildeslash.monit.plist
Parse the following lines into that plist file
<?xml version="1.0" encoding="UTF-8"?>
Now load monit
sudo launchctl load -w /Library/LaunchDaemons/com.tildeslash.monit.plist
- The monit daemon should be running now, test its status using command:
sudo monit status, if everything was done right, you should see the diagnosis information of the Mail process.
- Besides, monit serves a http server at address http://localhost:2812
The basic idea of this workaround is to monitor the CPU usage of process Mail, if it’s eating over 100% CPU for more than 1 minute, monit will restart it. Monit will check the status of Mail every 30 seconds (the default configuration), and it prints logs into the system log, you can access the log with system applicaton
控制台, e.g. To investigate if your Mail.app lose its mind for the last few days, open Console application and search
monit. If any entry out there, bla bla 1000 words for the excellent Mail.app!!! Also, you can check the uptime of Mail.app in the web page of monit with default user/password - admin/monit.