I recently ran into an issue where our Zope process was crashing. We have 4 Zope processes installed, 3 are load balanced with Zeo and the forth is for images files.
I created a script that would check the size of the log files for each instance and if the size of the log files was bigger than 1GB to rotate the logs and restart that particular Zope instance. The name of my script was logrotate.sh.
Now I wanted this script called at a specified day of the week and time so I couldn’t just add it to /etc/periodic/weekly, well I could and then change the time that the weekly scripts run but I didn’t want to change that system wide. If I wanted to change it though you would edit /System/Library/LaunchDaemons/com.apple.periodic-weekly.plist and edit the Hour, Minute, and Weekday integers as appropriate.
So I created my own plist and added it to /System/Library/LaunchAgents/edu.ucla.zoperestart.plist
Here’s what my plist looks like:
Now I had to load the plist so that launchctl was aware of it and would read the xml file and run it at the appropriate time.
launchctl load /System/Library/LaunchAgents/edu.ucla.zoperestart.plist
Verify that the plist is loaded:
I purposely set the date and time to 15 minutes in the future just to test that launchd ran my script. Now it’s working great!