To make a CRON

Hello everybody !

I’m a new Dolibarr developper, and I don’t find any documentation about the development of a CRON in my new module.

Can anybody help me please ?

Thx !

hello
what do you want to do exactly ?

Hi Altatof,

I want to generate a PDF (manage by my own module) everyday at 5:00 AM :happy:

hello
the easiest way is to write your script and create a cron task that launch it; i am not sure to understand your problem

1 Like

My module is generating a lot of invoices based on some parameters that I recover from my database (price, products…). And everyday, at 5PM, I want to generate automatically them, because in my society, we have some customers who are benefiting from a subscription :happy: (excuse my approximate english, I’m french haha)

hello,

Dolibarr version 3.9.3 / in OVH

I have make a cron with script.
If i test my cron => it 's OK.

But, when i do a date, hour and time with frequency, my cron is in my list but it’s never execute.

i forgot something ?

Hello,

Either there is an issue with your cron script or your cron setup.
If I were you, I will create a basic php code and keep the same cron settings; if it works then there is something wrong on dolibarr side ortherwise you will need to check the cron settings.

Hi,
I have just done it with version 8.0.2.

- In the module descriptor I have defined the cron as:

$this->cronjobs = array(0=>array('label'=>'SendRemainderNotification', 
	'jobtype'=>'method', 
        'class'=>'/remaindernotification/class/cron_notifyremainder.class.php', 
        'objectname'=>'NotifyRemainder', 
        'method'=>'SendReminder', 
        'parameters'=>'', 
        'comment'=>'SendRemainderNotificationComment', 
        'frequency'=>24, 
        'unitfrequency'=>3600, 
        'status'=>0, 
        'test'=>'$conf->remaindernotification->enabled',
));

- then I created the class file cron_notifyremainder.class.php.
In this file, I have defined the class NotifyRemainder with the method SendReminder

Here is the code sample:

[code]
class NotifyRemainder extends CommonObject
{

/**
 * Send reminders by emails
 * CAN BE A CRON TASK
 *
 * @return	int			0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
 */
public function SendReminder() {
    return $error;
}

}[/code]

I hope I was helpful
Marcello

1 Like