About Maintenance for Plone
Run scheduled scripts for routine work in a Plone site, like packing the ZODB.
Maintenance for Plone has been designed by the INGENIWEB team.
Maintenance for Plone 1.4.2 is licensed under the GNU GPL license.
Coming later !
PloneMaintenance consists of a portal_maintenance tool that allows you to define maintenance tasks and scripts to run according to a schedule assigned to the tasks.
No task is going to be run unless it is scheduled to. The schedule information is stored in the task, and even if PloneMaintenance is called many times in a row, it will always look up the schedule information, check when was the last time the task was run, calculate the next time the task is scheduled to run, and depending on this, PloneMaintenance will decide whether it runs the script associated to the task or not.
PloneMaintenance depends on an external tool to wake it up and make it execute the scheduled tasks. Without an external tool, PloneMaintenance will just sit and wait, doing nothing. You can go to the portal_maintenance tool and manually run the maintenance tasks, but most of the time, you want an external tool doing the job automatically.
You can choose one of the Schedulers which are available for Zope, or call PloneMaintenance from a cron job.
Zope 2.6: * http://www.zope.org/Members/lstaffor/Xron
This product installation requires to compile a python module. This compilation do not need to Visual C++ being installed. You just need to compile the module with the python used for your Plone installation. Go in $PloneProductsTimerServicetimerserverand run:
"C:Program FilesPlone-2.xZopebinpython.exe" setup.py install
Now windows didn't link correctly your module. You have to copy/paste the module in "C:Program FilesPlone-2.xZopelibpython".
All the schedulers have to do is call the runMaintenanceTasks Python Script that will take care of calling the runTasks method of the portal_maintenance tool. The runMaintenanceTasks script can be run by an anonymous user, because the PloneMaintenance tool makes sure to only run tasks that need to be run.
Another way of calling PloneMaintenance is by an unix cron job. All you need to do is to call http://mysite.com/runMaintenanceTasks every once in a while. Have a look at the following Howto on Zope.org:
Run cron jobs to do things automatically http://zope.org/Members/phd/cron-zope
When the PloneMaintenance tool is called, it locks itself using the _v_running variable. The next time a schedule is started, this lock will prevent the execution of the Tasks so that tasks that take a long time to execute are protected.
When a Task is created, an initial execution time is stored, although this does not mean we start the Task right away.
The PloneMaintenance tool executes one Task after the other, always storing the execution date. At the end, the lock is removed.
PloneMaintenance computes the next execution time given the current date and compares it to the next execution date, given the last execution date. If the two calculated dates are the same, it does nothing, otherwise it runs the task.
Tasks are added to the portal_maintenance tool. They have a "script_name" property that names the script which they execute, and they have a "last_execution_date", which stores the last time the task was executed.
Scripts are also added to the portal_maintenance tool. They can be normal Python Scripts.
Here is an example of a Maintenance Script for a Plone site:
# Script for packing the ZODB: # (Already integrated into PloneMaintenance) dbs=context.Control_Panel.Database if 'main' in dbs.getDatabaseNames(): try: dbs['main'].manage_pack(days=0) except: pass
Install PloneMaintenance from the Plone Configlet or using the QuickInstaller.
Note : Once you have an instance of the PloneMaintenanceTool, you should avoid uninstalling PloneMaintenance, otherwise you will lose any custom scripts and tasks.
Information about PloneMaintenance can be found at:
Released versions of Maintenance for Plone are available here. The current version is 1.4.2.
The repository contains the up-to-date versions of our source code. In order to get the HEAD branch of PloneMaintenance, use :
svn co http://svn.plone.org/svn/collective/PloneMaintenance/trunk
You can also browse the CVS with your browser.
Please take time the read the Readme
Using ZopeScheduler and TimerService
- unarchive these products in $INSTANCE/Products
2) Edit TimerService/timerserver/component.xml and move ten minutes interval to one :<key name="interval" datatype="integer" default="600">
Will become :<key name="interval" datatype="integer" default="60">
- Go in TimerService/timerserver and launch python2.3 setup.py install
4) For Windows administrators, copy $PYTHON_LIB/site-packages/timerserver in $ZOPE/lib/python
- Restart Zope
You will see something like that in event logs:
- 2005-11-04T08:39:44 INFO ZServer Timer server started at Fri Nov 4 08:39:44 2005
- Interval: 60 seconds.
Maintenance for Plone changes
- Fixed end of month computation
- Does'nt break ZMI if resqueted schedulong gives an impossible date: for example 11/31 or 2006/02/29
- Fix bug on MaintenanceTask: id was not initialized
- Add "notified_emails" property. When a task has been processed, an email is sent.
- MaintenanceTask no more addable types 2006/07/06 MR
- Handle force parameter 2006/05/31 MR
- Set last execution date when script fails 2006/05/19 MR
- Fix end of month is not the 31 bug
- Allow to run debug mode with a debug.txt file in the product 2005/11/07 ED
- Code cleaning 2005/11/07 ED
- Don't allow tasks to be added globally. 2005/10/04 MR
- Added "Select a script" to task drop down. A user could get the impression that a script was selected although he never chose one. 2005/09/29 MR
- Added some more logs
- Added and tested a script that allows updating the portal_catalog.
- Added, tested and improved a script that allows archiving the Plone site's expired content. 2005/09/15
- Improved the Install.py (allow reinstall without an error, code cleanup, etc)
- More importantly, fixed a bug with the rebuildCatalogs script not applying to the right context (i.e. the Plone site root). In the future, we should investigate replacing External Methods with tool-based helper methods or Zope 3 views/adapters.
- Add proxy role manager to runMaintenanceTasks script 2005/08/31
- Fixed problem for Plone 2.1 compatibility in Scripts.py and Tasks.py 2005/08/31
- Integrated "Rebuild Catalogs in a PloneArticle-aware way" script as an external method 2005/08/31
- Integrated "Pack ZODB" script as an external method 2005/08/31
- Reporting when scripts fail to run 2005/03/27
- Removed dependency on navigation_properties and form_properties (Plone 2.1) 2005/03/27
- runTasks returns a description of what was done 2005/03/15
- Added link for running maintenance tasks directly in maintenance tool 2005/03/15
- Added runMaintenanceTasks Python Script. Changed Readme to explain how to call this script. 2005/03/11
- Showing last execution time as well
- Last execution time is now correctly stored upon task execution
- Removed bogus imports - product was broken if ZAttachmentAttribute was not installed.
- Fixed Readme: Of course portal_maintenance/runTasks should be called, and not plone_maintenance/runTasks.
- The algorithm used to calculate the next execution date was simplified and refactored
- Adding Maintenance scripts in doc/maintenance_scripts.txt:
- Pack DB
- Update Catalog
- Removing seconds from DateTimes as they don't play a role
- Made sure that runMaintenanceTasks can be run by Anonymous
- Show scheduled tasks in Overview
0.2 2004/04/25 Maik Rder
- rewrote getNextScheduledExecutionTime
- Show warning in the Overview tab when no schedulers are installed
- Explain quickly where to look for info on installing a scheduler
- Explanation on the different ways of running PloneMaintenance
- adapted unit tests and wrote some
- added skin
0.1.1 2004/04/21 Maik Rder
- Log entries at the important points
- replaced _v_execution_date by execution_date
0.1 - 2004/04/19 Maik Rder
- Initial version
- Create a scripts folder for our scripts
- Show selection list for the existing scripts
- Scripts and Tasks come in their own folder.
- Added Tabs for these folders.
- Added Overview Tab
- Scripts can be added to Tasks with drop-down list
- Tested running Tasks
Maintenance for Plone ChangeLog is also available for detailed informations.