How to execute script

We found that they are some scripts useful - email_expire_services_to_representatives.php

Can we can use it in scheduled jobs?


I see no reason why you could not.


Hello Marc.

Is it possible to be more specific “step by step” how to add scheduled job for script email_expire_services_to_customers.php ?

Thanks in advance,

Hi Georges,

This will depend on your environment. Under linux (preferred), you will add a task in the crontab, something like :
0 8 * * * apache /home/dolibarr/scripts/contracts/email_expire_services_to_customers.php test contacts

Replace the ‘/home/dolibarr’ with the path to your installation and apache by the user that runs php in your website. Then, look at the script for proper options (you probably want to replace test by confirm and specify dates). And look at cron manual for adequate perodicity. The example above will run everyday at 8am.

On windows, you have to define a scheduled task, I am not familiar with that but it would work the same way.

Hope this helps,
Kind regards,

Hello Marc.
Still I can’t make it work.

I have a hosting on PLESK panel (under Linux).
I have added crontab to run every 5 minutes. Also replaced the ‘/home/dolibarr’ with the path of my installation(/var/www/vhosts/scripts/contracts/email_expire_services_to_customers.php) and apache by the user (/opt/plesk/php/7.4/bin/php)


/opt/plesk/php/7.4/bin/php /var/www/vhosts/scripts/contracts/email_expire_services_to_customers.php

I don’t understand the third part to look at the script for proper options “you probably want to replace test by confirm and specify dates” .

I’m sorry if I’m hard to understand. I’m completely newbie to Dolibarr.

Thanks in advance.

Hi Georges,

On top of the script, you find these drivers :

    print "Usage: $script_file (test|confirm) (thirdparties|contacts) [delay] [after]\n";
	print "\n";
	print "Send an email to customers to remind all contracts services to expire or expired.\n";
	print "If you choose 'test' mode, no emails are sent.\n";
	print "If you add param delay (nb of days), only services with expired date < today + delay are i
	print "If you add param after (nb of days), only services with expired date >= today + delay are 

This may help adjust the command line parameters.
Could you be more explicit on “it daes’nt work” => error messages, screenshots, logfile excerpts, whatever may help…

Hi Marc.

Well, I feel like something is missing in the whole process.
I have Dolibarr ver. 14.0.0 and the installation is in httpdocs folder. The “scripts” folder is outside of it.
I have not specified anywhere in Dolibarr where is located “scripts” folder.
How is it referenced to the data?

When I said, “Still I can’t make it work.” I meant that cronjob that I specify returned me an error( .

I thought it would be almost the same process as setting up Scheduled Jobs from Admins Tools with a URL that check and launch qualified cron jobs from a browser.


Looks like you haven’t specified 2 mandatory arguments, that is

  1. test or confirm
  2. thirdparties or contacts


Hi Marc.
I really appreciate your help. Thank you.

I just fixed it with the below command:

/opt/plesk/php/7.4/bin/php /var/www/vhosts/scripts/domain/contracts/email_expire_services_to_customers.php confirm thirdparties

and Ι also had error on file “email_expire_services_to_customers.php” line 55 on required path.

require $path."…/…/htdocs/";

I would like to ask you if is there a possibility to send notification emails 30, 15, 7 and 2 days before the end of the service as well as if there is a possibility to record it on event reports.

Thanks in advance.