a quick question about cronttab or equivalent

Hi, I use crontab for the "coming soon" product . I understand the basics of crontab and why I need it for this product. First explained to me by @cewing awhile ago.

My question is why do we need it? In Plone, you can set the publishing begin/end dates and the content responds. How does the piece of content know that the start/end date of the content has been reached. This is what I use crontab for with the other product (coming soon) What 'action' runs in place of crontab?

So whatever in Plone runs to tell the page to show/hide, how is that different from crontab and why can't we tap into it for other tasks.

Thanks hope you can set me straight :smile:

Hi, I had this exact question awhile ago and a few people, including Cris, set me strait.

I will try to explain, I will likely miss the mark and someone will correct me.

In Plone, the date/time specified for each page is used to make the publish/hide decision when publishing the view. Each time the page is rendered the publish/hide date is consulted to determine if the page should be displayed. (this is in addition to any permission constraints)

‘Cron’ (not Plone) is a unix feature and must be set at unix level.

I connect cron to Plone’s 'coming soon' addon to fire a content rule. The cron job fires as defined in the unix string (e.g. every day at noon). When cron fires, it trips 'coming soon' which takes an action (as defined in the assigned Content Rule).

So you can use cron and coming soon to send an email 3 days before an event on your site.

This action comes from a low level and nothing in Plone will do this without the cron job.

Hope this helps

1 Like

I will also note that publishing and expiration dates do not make any changes to the workflow. The item is still in the published state, even if it's before the publishing date, or after the expiration date, so the content can still be accessed at the url. The item is just not listed in search results or folder views when outside of the dates.

So if you want a workflow change to happen after the content has expired, that is something that could be controlled by a cronjob - it could check once a day to find items that have expired, and then change their workflow state to private.

1 Like

If you actually want to make things happen at certain dates you can use this - collective.contentrule.commingsoon

I suspect that's what phanhuyen12 is refering to with "coming soon product" :upside_down_face:

The others explained it well, just let me add some cents for further clarification:

In order to know if a date is met, a program has to look up the current date just like a human needs to look at a clock or the position of the sun, to know what time it is. And that program has to be executed.

Taking this analogy, the difference is that the human triggers the execution of looking up the date by sending an HTTP-request, whereas the the cron counts through N time-units (e.g. "every 24 hours") and when N is met, triggers the execution and is doomed to continue counting foreva.

So it depends on the usecase which way one needs to go: If you want move items into an archive-folder automatically every night, you can either set up a cron, or get up at midnight, and call the program via an HTTP-request. If you want to exclude expired content of a listing-view for site-visitors (like it's the default in Plone), no cron is needed, because user's calling.