Help with scheduled jobs!

Can someone provide a proper documentation for setting up scheduled jobs in Dolibarr.
It has not been documented anywhere and is very confusing with the need to call the script externally.
I have set it up once successfully. But when I’m trying to do it for a second time from scratch, it fails.
The maintenance of Dolibarr using these scheduled jobs are important for removing temp files and for SQL backup.

I use Dolibarr version 12.0.4

Hi,

Could you describe a bit what is the issue ?

Hi Sac

 Just try as below :

1.Download dolibarr-12.0.4.zip from dolibarr download page .
2.Unzip the file .
3.Find the file " cron_run_jobs.php " in " scripts/cron/ " .
4.Copy " cron_run_jobs.php " to your website root folder .( For windows system it will be in your xampp folder and if your system is linux , it will be in /var/www/html/ . )
5.Open " cron_run_job.php " by any editor .
6.Edit line 45 [ require_once $path."…/…/master.inc.php";" ] to [ require_once $path.“master.inc.php”; ].
Note: You also could copy the cron_run_jub.php to the other folder , but you will need to change the path to real path .
7.Go to your dolibarr Home >> Setup >> Modules/Application setup >> SCHEDULED JOBS.
8.Enable " SCHEDULED JOBS " module if you have not enable it .
9.Create " Security key for URL to launch cron jobs " and press save .
10.Go to Home >> Admin Tools >> Scheduled jobs
11.Click the link below " URL to check and launch qualified cron jobs: " to test the cron job .
12.If it works it will as like below :cron_run_jobs.php cronjobid: 2 priority=10 entity=1 label=SendEmailsReminders - qualified - result of run_jobs = 1 - reprogrammed cron_run_jobs.php cronjobid: 4 priority=50 entity=0 label=PurgeDeleteTemporaryFilesShort -> we change entity so we reload user and conf - not qualified cron_run_jobs.php cronjobid: 1 priority=50 entity=1 label=SendReminderForExpiredSubscriptionTitle - not qualified cron_run_jobs.php cronjobid: 3 priority=50 entity=1 label=RecurringInvoices - not qualified cron_run_jobs.php cronjobid: 5 priority=90 entity=0 label=MakeLocalDatabaseDumpShort -> we change entity so we reload user and conf - not qualified Result: 5 jobs - 1 launched = 1 OK + 0 KO
13.Test cron job command in your host .( If in windows you could use cmd and type as below to test : { D:\Xampp\php\php.exe D:\Xampp\htdocs\cron_run_jobs.php your_Security_key your_admin_name cronid } . If you use linux system , just use terminal to excute like { php cron_run_jobs.php your_Security_key your_admin_name cronid } .)
14.Add the cron job command to your Scheduled Task tools in windows .
In linux ,you will need to add command line in the end of Scheduled jobs page " */5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php xzR787r1izJOtgRibPW9I87tIF5Iq6L5 admin > /var/lib/dolibarr/documents/cron_run_jobs.php.log " into your contab .

1 Like

It’s not working. I gave up after trying for a long time.
As of now I am using a tool, SQLBackupAndFTP for taking SQL dumps regularly (along with folder backup for docs).
It is a great free solution for anyone looking to set up a robust automated backup plan.
It even sends email in case of backup failure.
I felt this to be superior to the inbuilt scheduled backup of Dolibarr.

I get this error,
***** cron_run_jobs.php (12.0.4) pid=10940 ***** userlogin=admin ***** 2021-01-05T22:18:18Z *****
cron_run_jobs.php cronjobid: 2 priority=50 entity=0 label=PurgeDeleteTemporaryFilesShort - not qualified

Hi Sac

What is your command line looks like ??
Like as below ?
…/scripts/cron/cron_run_jobs.php 0l6izKXDrxM3Id5M24bG29uGZm56yXzT admin [cronjobid]

1 Like

…/scripts/cron/cron_run_jobs.php 9VE852BdChlCi2xyT2Vvi7dTLFYrs541 admin [cronjobid]

Hi Sac

I have tried to do the procedure again in windows system.
But i cound not find the way to fix it .
Maybe we will need to wait someone to test it .

1 Like

@trekmorris I hope so.
@ksar Could you please look into this? Is this functioning for you in 12.0.4?

Hi sac

I may find the problem is .
Please go to Admin tools >> about Dolibarr .
And check the " TimeZone PHP (server) " is same as your server .
If not , please open the php.ini file and search " date.timezone " to correct it .
Then go to Scheduled jobs page and change " Local database backup " setting to execute this
job per 10 mins to test .

2 Likes

The zone is same in both places.

Hi sac

As my testing , if i click the cron job testing url and get error "not qualified " is normal .
That because you have enabled the cron job in dolibarr , but the windows schedule task tool has not executed the cron_run_jobs.php yet .
If you look at the task tool history , and that command works every 5 mins , then you could go back to see the backup page to see if dolibarr get new backup or not . (Note. Please set local database backup job execute per 10 mins to test .) And because it need to wait for windows task tool to execute cron_run_job.php , so it maybe would delay for 3 or 4 mins to get new backup file .

1 Like

Thank you for these explanations. It helps us a lot.

1 Like