Results 1 to 4 of 4

Thread: Execute cron jobs on the server

  1. #1
    New user
    Join Date
    01-20-12.
    Posts
    6

    Default Execute cron jobs on the server

    Hello,

    I can't make the cron jobs working.
    I've read the documentation here : https://docs.contao.org/books/cookbo...in-Contao.html

    What I've done :
    1. unchecked in the system configuration page the checkbox so the cron.php can be executed by a real cron job
    2. create on my server a cron job like that : * * * * * wget -O /dev/null -q http://example.com/system/cron/cron.php
    3. in the config.php file of my extension; I've added the classe :
    $GLOBALS['TL_CRON'] = array
    (
    'monthly' => array(),
    'weekly' => array(),
    'daily' => array(),
    'hourly' => array(),
    'minutely' => array( array('STBRappels', 'envoyerRappels'))
    );

    That doesn't work. I only receive a mail from my server so I know that the cron job is fired.

    But if I execute cron.php manually (as explained in the doc), it works.

    Thanks a lot for your help.
    Olivier

  2. #2
    User Spooky's Avatar
    Join Date
    01-03-13.
    Posts
    339

    Default

    Quote Originally Posted by oli03 View Post
    3. in the config.php file of my extension; I've added the classe :
    PHP Code:
      $GLOBALS['TL_CRON'] = array
      (
         
    'monthly' => array(),
         
    'weekly'   => array(),
         
    'daily'    => array(),
         
    'hourly'   => array(),
         
    'minutely' => array( array('STBRappels''envoyerRappels'))
      ); 
    Regardless of your actual problem: you should not do it this way. Because this way you delete all other cronjobs of Contao. Instead, do this:
    PHP Code:
    $GLOBALS['TL_CRON']['minutely'][] = array('STBRappels''envoyerRappels'); 

    Can you log in via SSH to your server and execute
    Code:
    wget -O /dev/null -q http://example.com/system/cron/cron.php
    manually from there?

  3. #3
    New user
    Join Date
    01-20-12.
    Posts
    6

    Default

    Thank you for your answer.
    You're right, thank you for this correction.

    I don't understand why we have to choose between 'monthly','weekly','daily','hourly','minutely' in the config file as we decide the frequency on the server.

    EDIT
    Ok, it works. I now receive an email every minute.
    I will try every hour ou every day.
    Last edited by oli03; 09/15/2015 at 10:52.

  4. #4
    User Spooky's Avatar
    Join Date
    01-03-13.
    Posts
    339

    Default

    Quote Originally Posted by oli03 View Post
    I don't understand why we have to choose between 'monthly','weekly','daily','hourly','minutely' in the config file as we decide the frequency on the server.
    That's not how it works. You decide via $GLOBALS['TL_CRON']['…'] how often a specific job should be executed, regardless of how often cron.php is actually called. There are certain jobs in the Contao core which are only executed once every month for instance. However the cron.php itself might be called minutely or even secondly.

    By doing
    PHP Code:
    $GLOBALS['TL_CRON']['minutely'][] = array('STBRappels''envoyerRappels'); 
    you are essentialy defining that this job is executed at most once every minute, but not more often than that (even if the cron.php is called more often than that).

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •