<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-AU link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>This kind of thing has been discussed periodically over the years but it never really gets anywhere.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>I think using cron might be shoehorning things a bit. Cron is great for packaged routine cronjobs and system administration stuff, but for application workloads… I’m not so sure. What about Celery (<a href="http://www.celeryproject.org/">http://www.celeryproject.org/</a>) or Gearman (<a href="http://gearman.org/">http://gearman.org/</a>) or some other job server?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>For <a href="https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=10662">https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=10662</a>, I actually wrote my own job server using POE::Component::JobQueue (<a href="https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=10662&attachment=71008">https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=10662&attachment=71008</a>). (Originally, I wrote a generic job/task server for all of Koha but then I figured I was trying to be all things to all people, so I scrapped that idea and just made my OAI-PMH harvester daemon deal with OAI-PMH tasks/jobs. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>In my code, I actually have 2 job queues. The 1st queue is actually in the MySQL database, and the daemon polls the database to finds import jobs. It’s not the best solution, but I think I wanted a certain amount of persistence to that queue and to interrogate the data without talking to the job server. The 2<sup>nd</sup> queue is an in-memory queue. The Koha web user sends a message to the daemon telling it to down from an OAI-PMH server, the job server enqueues the job, and then a predetermined number of workers are forked to do the work of N jobs. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Oh I also made the queue workers pluggable so that it was easy to make workers do whatever. I just made sure they had a run() method that expected certain arguments from the job server. After that, worker plugins were free to do whatever they needed to do. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Anyway, that’s just my 2 cents.  Cron is a tried and true job scheduler for sure… but I don’t think it is the be all and end all. (If you do go with 1 cronjob to rule them all, you’ll need to think about locking, so that long-running cronjobs don’t end up clobbering each other and generally creating havoc. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>I was looking for more resources on task queues when I actually found this: “A cron job makes an HTTP GET request to a URL as scheduled. The handler for that URL executes the logic when it is called.” <a href="https://cloud.google.com/appengine/docs/standard/python/config/cron">https://cloud.google.com/appengine/docs/standard/python/config/cron</a>. This doesn’t look like a true “cron” job either though. It looks like a custom scheduler running for the App Engine. But I see how they contrast those regularly scheduled “cron” jobs versus a task queue (<a href="https://cloud.google.com/appengine/docs/standard/python/taskqueue/">https://cloud.google.com/appengine/docs/standard/python/taskqueue/</a>) although Google’s implementation uses “due dates” to let you do a one-off type of scheduling. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Ultimately, it depends on how fine grained you want things to be. I suppose you could have cronjobs set up daily, hourly, monthly, and weekly (using cron.daily/cron.hourly/cron.monthly/cron.weekly… although I think some OSes use anacron for some of these?) and then have those poll the Koha database for a “cron” table where plugins and such can configure jobs. I mean… it would be the “lighest touch”. Like I said above,you’d want to think about locking, but other than that… it would work. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Maybe a mix of all the above…<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>David Cook<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Systems Librarian<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Prosentient Systems<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>72/330 Wattle St<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Ultimo, NSW 2007<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Australia<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Office: 02 9212 0899<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Direct: 02 8005 0595<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> koha-devel-bounces@lists.koha-community.org [mailto:koha-devel-bounces@lists.koha-community.org] <b>On Behalf Of </b>Nick Clemens<br><b>Sent:</b> Friday, 8 June 2018 3:48 AM<br><b>To:</b> Koha Devel <koha-devel@lists.koha-community.org><br><b>Subject:</b> [Koha-devel] Cronjob to run plugin cronjobs?<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>Just an idea I had an bounced off Kyle, he suggested sending it out for feedback, let us knwo what you think:<o:p></o:p></p></div><div><p class=MsoNormal><a href="https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20897">https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20897</a><o:p></o:p></p></div></div><p class=MsoNormal>-- <o:p></o:p></p><div><div><div><div><div><p class=MsoNormal>Nick Clemens<o:p></o:p></p></div><p class=MsoNormal>Sonic Screwdriver (Development Support)<o:p></o:p></p></div><p class=MsoNormal>ByWater Solutions<o:p></o:p></p></div><p class=MsoNormal>IRC: kidclamp<o:p></o:p></p></div></div></div></body></html>