How to create 2 tasks in 1 cronjob?

Last modified by Stéphane Laurière on 2014/04/08 19:32

We assume that you want to implement 2 taks - 1 on the 1st and the 15th of the month - 1 only on the 15th

Then for the the monthly task, you can just add a simple php test

<?php
// Variables - déclaration
$doCronJob1;
$doCronJob2;
 
// Premier jour du mois -- on fait les deux updates
if (date("j") == "1"){
   $doCronJob1 = true;
   $doCronJob2 = true;
}
else if (date("j") == "15"){
   $doCronJob1 = true;
   $doCronJob2 = false;
}
else{
   // Ni le 1er, ni le 15 du mois, exit
   die(1);
}
 
// Perform updates
if ($doCronJob1){
    // ...
}
 
if ($doCronJob2){
    // ...
}
?>

see [1] for details

Tags:
Created by Stéphane Laurière on 2012/09/14 14:38

Partners

Orange

VOICES

EU - FP7

OW2

© Emerginov
Site maintained by OW2