Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best task scheduling approach in Plone 4?

We need to schedule some tasks in Plone 4 (notify users after n days of inactivity, etc.). What is the best way to do it? Is there something in Plone or maybe an old cron job? I would like to avoid cron4plone.

like image 918
amleczko Avatar asked Jun 08 '12 10:06

amleczko


1 Answers

Simply use the built-in <clock-server> functionality in zope.conf; list them in the zope-conf-additional option of plone.recipe.zope2instance:

zope-conf-additional =
  <clock-server>
    method /Plone/path/to/callable
    period 7200
    user username-to-invoke-method-with
    password password-for-user
    host localhost
  </clock-server>

The above snippet will call /Plone/path/to/callable every 2 hours, with the Host header set to localhost with the configured user and password.

The clock-server was added to Zope 2.10; before this it was a separate product by Chris McDonough. I generally created dedicated views for such tasks.

The alternative is to use a cron job to call either a view (usually with wget or cron) or a zopectl command line script. I use this when I need precise control over when the script needs to be executed, such as at midnight every day.

like image 70
Martijn Pieters Avatar answered Nov 10 '22 18:11

Martijn Pieters