feel free to keep it strictly simple...

Cronjob Feature

Starting with LEPTON 7.0.0 core got a cronjob class to ease the execution of internal and external cronjobs.

With the installation of (or upgrade to)  LEPTON 7.0.0 you got some additional files:

  • class lepton_cronjob in  /framework/classes
  • cronjob.php in modules directory
  • cronjob_ini.php in config directory
  • cj_example.php file in /temp/secure

but you ou only have to care about the last 2 files.

You also got a new entry in your lepton.ini.php that enables internal cronjobs for frontend and/or backend:

CRONJOB = 0        ; 0 = disabled, 1 = FE only, 2 = BE only, 3 = BE + FE

 

Handle files: cronjob.ini.php

The file cronjob.ini.php holds all neccessary values (similar to lepton.ini.php) and you have to edit the values to your needs.
You can also add as much values as you like in the custom area for use in your cronjob file.
The [file_info] values are automatically handled by the class LEPTON_cronjob.
The [custom_values] have to be handled by yourself, see example below.

; Setup cronjobs [file_info] path = '/temp/secure/' file = 'cj_example.php' key = '123456' ; key must have a length referring to AUTH_MIN_PASS_LENGTH intervall = '3600' ; minimum time in sec between execution of cronjob [custom_values] ilog_file = '/temp/cron_log_intern.txt' elog_file = '/temp/cron_log_extern.txt' message_type = 3
last edit: 28. Jul 2023 CEST 17:56:06

Handle files: cj_example.php

In this file you can put all your devices and code for your cronjob. Please try the following code for a first test

if(isset($_POST['ekey']) && $_POST['ekey'] == '123456') // check the ekey value!!! { $oLCJ = LEPTON_cronjob::getInstance(); $ilog_file = LEPTON_PATH.$oLCJ->cj_array['custom_values']['ilog_file']; $elog_file = LEPTON_PATH.$oLCJ->cj_array['custom_values']['elog_file']; $message_type = $oLCJ->cj_array['custom_values']['message_type']; echo (LEPTON_tools::display($_POST['ekey'],'pre','ui positive message')); } elseif(isset($_POST['ikey'])) // check internal call { echo (LEPTON_tools::display($_POST['ikey'],'pre','ui positive message')); } echo (LEPTON_tools::display('My cronjob works','pre','ui positive message'));
last edit: 03. Aug 2023 CEST 13:22:43

 

Working with those cronjobs is different.

1. external cronjobs

If you want to run your cronjob please simply call the url 

https://your_domain.tld/modules/cronjob.php?key=your_key_from_cronjob_ini_file

in your browser or use this url for calls by a service provider (something like cronjob.de).

Thats it.

Please take care that you don't get unwanted cronjob calls by checking some values (see example code above).

 

2. internal cronjobs

If you want to run your cronjob every time the backend or frontend of your installation is called you have to switch the value CRONJOB in your lepton.ini.php to 3.

This ensures the cronjob is called depending on the value in your lepton.ini.php.

Support

If you got further questions or you run into troubles please use the LEPTON forum.