Vtiger CRON - radus28/Vtiger-DevOps GitHub Wiki

Introduction

The vTiger cron jobs are designed to help schedule and automate processes. Cron jobs are executed in “Scheduled job” features in vTiger,

  • Scheduler can be configured at Settings > Automation > Scheduler
  • To run vtiger cron add /crons/vtigercron.sh into System's cron file (crontab -e )
  • The scheduled tasks are executed are
    • Workflows
    • Recurring Invoices
    • Mailscanner
    • Scheduled Reports
    • Scheduled Imports (csv)
    • Reminders

Run CRON from browsers

  1. Open /vtigercron.php in any editor
  2. Add a 'return' statement under the function vtigercron_detect_run_in_cli()
  3. Call this file from browser like http://YOUR-CRM_URL/vtigercron.php

How to add a CRON scheduler task

Method #1 Open vtiger_cron_tasks table and add your task

Method #2 Put below script in a .php and run from migrations/scripts/ folder

    `include_once('../../config.inc.php');// check relative path`
    `include_once ('vtlib/Vtiger/Cron.php');`
    `$cronName = 'YOUR-CRON-NAME';`
    `$module = 'YOUR-MODULE';` 
    `if (!Vtiger_Cron::getInstance($cronName)) {`
        `$sequence = \Vtiger_Cron::nextSequence();`
        `$description = 'Recommended frequency for Macro is 15 mins';`
        `$status = \Vtiger_Cron::$STATUS_ENABLED;`
        `Vtiger_Cron::register($cronName, "Crons/modules/".module.$cronName.".service", "300", "Settings", $status, $sequence, $description);`
    `}`