BISO uses crunz as the central task scheduler. Instead of setting up a separate cronjob for each recurring task, only a single cronjob is required. The scheduler independently checks which tasks are due and executes them.
The task files are located in the webroot/backend/scheduler/tasks/ directory. Individual tasks
are conditionally activated depending on configuration (Config) or parameters (Admin > Parameters).
On the customer system, a single crontab entry must be set up that runs every minute:
* * * * * www-data /usr/bin/php /var/www/biso/webroot/biso-cli scheduler run
Note: The path
/var/www/biso/webroot/must be adjusted to the respective installation.
The scheduler delegates to crunz, which reads the individual task files and only executes the tasks due
at the respective time. Overlapping executions are prevented by
preventOverlapping().
| Command | Description |
|---|---|
php biso-cli scheduler list |
Show all registered tasks with schedule |
php biso-cli scheduler run |
Execute due tasks |
php biso-cli scheduler run --force |
Execute all tasks immediately (independent of schedule) |
php biso-cli scheduler run --task=N |
Execute a specific task by number |
To add a new scheduler task, create a new PHP file in the directory
webroot/backend/scheduler/tasks/. The filename must end with Tasks.php
(e.g. MyNewTasks.php).
Basic structure of a task file:
<?php
use Crunz\Schedule;
require_once __DIR__ . '/../../../components/composer/kadenpartner/gaia/bootstrap.php';
$schedule = new Schedule();
// Conditional activation (optional):
if (Param::get('mein_feature_aktiv', false)) {
$schedule->run(PHP_BINARY . ' ' . Config::get('rootdir') . '/biso-cli mein-command')
->daily()->at('08:00')
->description('Beschreibung des Tasks')
->preventOverlapping()
->appendOutputTo(Config::get('tmpdir') . '/mein-task.log');
}
return $schedule;
| Method | Description |
|---|---|
->everyMinute() |
Every minute |
->hourly() |
Hourly |
->hourlyAt('15') |
Hourly at minute 15 |
->daily() |
Daily at midnight |
->daily()->at('08:00') |
Daily at 08:00 |
->weekly() |
Weekly |
->weeklyOn(1, '13:30') |
Weekly on Monday at 13:30 (0=Sunday) |
->monthly() |
Monthly |
->cron('30 8 * * Mon,Fri') |
Arbitrary cron expression |
->preventOverlapping() to prevent parallel executions of the same task->appendOutputTo(Config::get('tmpdir') . '/taskname.log') to write output to a log file->description('...') so the task is identifiable in scheduler listEach task writes its output to its own log file in the data/tmp/ directory:
SMS reminders can be sent via SMTP gateway.
In Config.php, the SMS gateway mail domain and sender must be set:
Config::set('sms_gateway_mail_domain', 'smsc.admin.ch');
Config::set('sms_gateway_mail_sender', 'info@kunde.ch');
Config::set('sms_ausloeser_username', 'admin');
| Parameter | Label | Meaning |
|---|---|---|
| sms_versand | With appointment SMS | Appointment SMS module on/off |
| sms_notification_time | Reminder distance in hours | Defines the time distance before the appointment at which an SMS reminder is triggered |
| sms_versand_manuell | Trigger manually | SMS can be triggered manually via the appointment interface |
| sms_versand_termin_vorlage | Appointment template | Template for BF appointments can be max. 160 characters long |
| sms_versand_test_vorlage | Group test template | Template for group test appointments can be max. 160 characters long |
So that the appointment SMS mails are sent to the SMS gateway, the CLI command
biso-cli termin-sms --do-it must be executed at regular intervals.
Example Linux crontab:
0 * * * * www-data /usr/bin/php /var/www/biso/webroot/biso-cli termin-sms --do-it
After case completion, cases can be supplied with a follow-up email. For this, the following prerequisites are necessary:
The follow-up survey is triggered via cron job, e.g. daily:
$ php webroot/biso-cli send-nachbefragung
The following configurations are relevant for follow-up surveys:
Customer-specific configs
Config::set('nachbefragung.ausnahme_termin_distanz_tage', 14): Exception: If the last appointment
is x days before case completion, no sending is triggeredThe follow-up CLI job logs its output to a separate logging target:
SendNachbefragung
The logs can therefore be directed to a dedicated logfile or to the console:
// config.php:
Config::set('LOGGING', [
'SendNachbefragung' => [
'type' => Logger::TYPE_CONSOLE,
'level' => Logger::DEBUG,
]
]);
The log system requires a second database with the Log table.
CREATE DATABASE biso_log
WITH
OWNER = bisoadm
ENCODING = 'UTF8'
LC_COLLATE = 'de_CH.utf8'
LC_CTYPE = 'de_CH.utf8'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
CREATE TABLE IF NOT EXISTS log
(
id serial NOT NULL,
logtime timestamp,
context text,
benutzer text,
action text,
record_id int,
record text ,
CONSTRAINT log_pkey PRIMARY KEY (id)
)
In Config.php, a second DB connection must be entered, and the log system can be activated separately for Store or Destroy actions.
$db['log'] = array();
$db['log']['pdo-dsn'] = 'pgsql:host=XXX.XXX.XXX.XXX port=5432 dbname=biso_log';
$db['log']['username'] = 'bisoadm';
$db['log']['password'] = 'PASSWORD';
$db['log']['schema'] = 'public';
Config::set('LOG_STORE', false);
Config::set('LOG_DESTROY', true);
See Background Job System for documentation of the job queue system.