This website uses Cookies to provide you with the best possible service. Please see our Privacy Policy for more information. Click the check box below to accept cookies. Then confirm with a click on "Save".  
Status: 2025-02-13

Cron


Cron config

Edit the _cron.php file in the configuration folder of your module.

Add routes that are to be called recurrently.

Example: modules/Foo/etc/config/Foo/config/_cron.php

<?php

/**
 * just list concrete Routes to be called
 */
$aConfig['MODULE']['Foo']['cron'] = [

    #-------------------------------------------------------------------------------------------------------------------
    # queue
    # starts all workers that are listed in config `etc/config/{module}/config/_worker.php`.

    // which is: '/~/queue/worker/run'
    $aConfig['MVC_QUEUE_RUN'],

    // start WebSocket Server
    '/ws/serve/'
];

list cron configuration

list cron configuration

php emvicy cron:list

Example output

# Cron List
# config: /var/www/html/modules/Foo/etc/config/Foo/config/

| No  | Route                                                                                                                 |
|-----|-----------------------------------------------------------------------------------------------------------------------|
| 1   | /~/queue/worker/run                                                                                                   |
| 2   | /ws/serve/                                                                                                            |

run cron

all routes listed in the Cron config are called non-blocking via Process::callRoute()

runs emvicy cron configuration

php emvicy cron:run

crontab

Example crontab

#----------------------------------------
# Emvicy 2.x
* * * * * cd /var/www/html; /usr/bin/php emvicy cron:run > /dev/null 2>/dev/null;