# Cron Master Usage Documentation

## 1. Introduction

This document provides instructions on how to use the Cron Master script to manage and execute cron jobs for various licenses.

## 2. Usage
To run the Cron Master script, use the following command:

```bash
/usr/bin/php7.4 php $WORKDIR/src/cron/masterCron.php <cron_name>
```

Replace <cron_name> with the name of the cron job you want to execute.

Example:
```bash
/usr/bin/php7.4 php $WORKDIR/src/cron/masterCron.php stats_daily_archive
```

## 3. Adding a New Cron Job

To add a new cron job to the CronService, follow these steps:

1. **Add the Cron Job to CronHelper:** Define the cron job in the CronHelper class with the necessary configuration.  
2. **Add the Cron Job to the Database:** Insert the cron job into the database table that stores all cron jobs (crons).  
3. **Link the Cron Job with Licenses:** Ensure the cron job is associated with the relevant licenses in the database (licences_crons).

Example:

#### Step 1: Add the Cron Job to CronHelper

```
    'new_cron_job' => [
        'script_name' => 'new_cron_job.php',
        'is_specific' => true,
        'timeout' => 3600,
        'cronExpression' => [
            Licence::CRON_PRIORITY_LEVEL_LOW => '*/10 * * * *',
            Licence::CRON_PRIORITY_LEVEL_MEDIUM  => '*/5 * * * *',
            Licence::CRON_PRIORITY_LEVEL_HIGH  => '*/1 * * * *',
        ],
        'argumentFormat' => '%s',
    ],
```

#### Step 2: Make the migration to add your cron to the list

CF: [migration](../../Migrations/MediaManager/Version20250225151502.php)

##### Mapping cron => id

```
[
    1 => 'arrowChat',
    2 => 'assignRegisterImportedVideoToCategory',
    3 => 'breakout-update-meetings-count-live-participants',
    4 => 'categoryCongresSessionsSearchDataReset',
    5 => 'chat_connectes_disconnect',
    6 => 'chat_connectes_logs_geoloc',
    7 => 'containerSearchDataReset',
    8 => 'disconnectIdleUsers',
    9 => 'download_videos_from_url',
    10 => 'email_preinscription',
    11 => 'generateAttestations',
    12 => 'generateExportPowerBi',
    13 => 'licence_clean_shared_files',
    14 => 'mediaImport',
    15 => 'messengerUnreadMessages',
    16 => 'nbconsult_sync_platform',
    17 => 'notificationMobileToRegister',
    18 => 'statsExtractWorker',
    19 => 'stats_daily_archive',
    20 => 'synchronizeEcongressPrograms',
    21 => 'synchronizeEcongressUsers',
    22 => 'synchronizeEventManagementProgram',
    23 => 'synchronizeRegisterBookmarks',
    24 => 'synchronizeRegisterPrograms',
    25 => 'synchronizeRegisterUsers',
    26 => 'tealiumStatisticsPost',
    27 => 'update-media-pages-vimeo-thumbnails',
    28 => 'vimeoSubtitlesMakeTranslation',
    29 => 'updateMediaAccessRules',
    30 => 'updateMediaTypeAndContentType',
    31 => 'checkIpToBlackList',
]
```
