How to create 2 tasks in 1 cronjob?


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