I want to setup a cronjob (or other method) to make a daily call to poke collective.contentrules.comingsoon content rule. This will then be used by a content rule I have to send notifications if certain events happened.
It appears there are (at least) two ways to accomplish this.
the main difference is pretty clear if you read the documentation:
a crontab job has to use a Zope user
a Zope clock server can user a Plone user
we use the clock server in 2 sites to run tasks every hour: in one (the Olympics site) we use it to read a YouTube feed a replicate the content; in the other (a magazine) we use it for 3 different tasks like updating economic data and importing content.
in the past we were using a separate instance; we moved to reuse our current instances to save memory with some speed costs, as some of this tasks take way too long to finish (we probably need to refactor them).
obviously you can achieve more flexibility on when to run the tasks with crontab, but I still prefer the clock server.
Hi, short Question:
Should be the instance down or can the instance running, if the cron call "bin/instance src/namespace.mypackage/namespace/mypackage/bin/script.py" ?
You need to run Plone in a ZEO setup for running a script through Cron without service interruption. Otherwise the ZODB is locked by the normal instance process.
Ok, my ZeoSetup client1, client2, client3. The client3 is only for the Cronjobs and not available for my Loadbalancer in front. Should i start the client3 normally with all other clients or should only the CronJob start/stop the client3 ? I'm a little confused.
There are two ways you can interact with your Zope instance: via HTTP automization or directly interacting with the Zope objects and infrastructure.
With HTTP automization, your script emulates a browser (and the human interacting with the browser). For this to work, your Zope process must be "running" (i.e. it must be started).
If your script interacts directly with Zope, it is not emulating a browser but accesses directly with either the Zope objects or its functions. There is no need that Zope is running -- the important active instance is your script (and maybe the ZEO or other database servers).
If you use bin/client<x> run ..., your script is able to interact directly with Zope; thus, no need to use bin/client<x> start before you start your script.
I have usually one spare ZEO client for such cases - either for debugging or for running such jobs outside the loadbalancer scope. I should be possible to "run" a script if a ZEO client that is already running but I would not recommend it. It is in general a good recommendation have a spare ZEO client with debugging settings enabled by default for debugging...it's handy and does not require any further resources.