This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Blogs » Thiago Campos Viana » Tip: Minimum cronjob extension

By

Tip: Minimum cronjob extension

Tuesday 14 February 2012 3:07:28 pm

  • Currently 3 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

In this blog post I will show how to setup a cronjob extension.

Let's create our folder structure inside extension folder first:

  • mycronjob
    • settings
    • cronjobs

Then let's define that this extension has cronjob scripts by creating the mycronjob/settings/cronjob.ini.append.php file:

<?php /*
 
 
[CronjobSettings]
ExtensionDirectories[]=mycronjob
 
# We can also create custom cronjob part here, so we can invoke by php cli and crontabs
# We can also add scripts or redefine an existing cronjob part.
[CronjobPart-mycronpart]
# Scripts[] to redefine an existing cronjob part
Scripts[]=mycronscript.php
 
*/ ?>

Inside cronjobs folder we create our scripts that we have defined in the conjobpart settings, in this case it will be cronjobs/mycronscript.php :

<?php 
 
 
 
// code goes here
 
 
?>

To invoke your cronjob you need to use php cli:

php runcronjobs.php mycronpart

Proudly Developed with from