Question:

I installed Vtiger CRM on my server, and I want to set up a cron job to trigger Vtiger CRM's cron job script. What should I do to set up the cron job?

Answer:

Our webcron service is best for triggering Vtiger CRM's cron job script. Just follow below simple steps to configure cron job for your Vtiger CRM:

  1. Open your cron job dashboard, click on " Cron Job" button.
  2. For the "URL to call" field, a little hack is needed to make it work. There are some ways (some are simpler and the other may be safer) to do the hacking.

    A simpler way:
    In file vtigercron.php, change the line

    if(vtigercron_detect_run_in_cli() || (isset($_SESSION["authenticated_user_id"]) &&	isset($_SESSION["app_unique_key"]) && $_SESSION["app_unique_key"] == $application_unique_key)){
    
    to
    if(vtigercron_detect_run_in_cli() || ($_REQUEST["app_unique_key"] == $application_unique_key) || (isset($_SESSION["authenticated_user_id"]) &&	isset($_SESSION["app_unique_key"]) && $_SESSION["app_unique_key"] == $application_unique_key)){
    and then use
    http://www.example.com/vtigercron.php?app_unique_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    as cron job URL.
    IMPORTANT NOTICE: You may find your app_unique_key in config.inc.php (search $application_unique_key in it). Please replace xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx in the URL above with the 32-chars $application_unique_key you find in config.inc.php, and www.example.com with your vtiger install location.

    A safer way:
    In file vtigercron.php, change the line

    if(vtigercron_detect_run_in_cli() || (isset($_SESSION["authenticated_user_id"]) &&	isset($_SESSION["app_unique_key"]) && $_SESSION["app_unique_key"] == $application_unique_key)){
    to
    if(vtigercron_detect_run_in_cli() || ($_REQUEST["password_for_easycron"] == "PASSWORD") || (isset($_SESSION["authenticated_user_id"]) &&	isset($_SESSION["app_unique_key"]) && $_SESSION["app_unique_key"] == $application_unique_key)){
    and then use
    http://www.example.com/vtigercron.php?password_for_easycron=PASSWORD
    as cron job URL.
    IMPORTANT NOTICE: Please replace those 2 capitalized PASSWORD in the code and URL with a same secret password, and www.example.com with your vtiger install location.

    Some even safer ways also exist (e.g. using HTTP header to post the PASSWORD). You could find an appropriate solution for your situation.

  3. Choose an appropriate cron job execution frequency. Check out below screenshot:

    Set up cron job for Vtiger CRM
  4. If necessary, finish the other optional settings.
  5. Click "Create Cron Job" button. You're done! EasyCron will trigger your Vtiger CRM's cron job script dutifully according to your time setting.
  6. If you haven't registered your EasyCron account yet, click on the "add a password" link on the top to add an email and password to your account.