Cron drupal 8 for my module? I am doing a module in drupal 8, I would like to know how to execute a function automatically every month. I think it's done with Cron, but I only get to do it every week. as I edit it from my function.
A modified example from cron_example module. This doesn't concern the interval the cron tasks are set in cron. 

This is important, as you will probably set another cron tasks sooner or latter with different interval requirements. Also, many system tasks require more frequent cron runs.

function cron_example_cron() {
  $interval = 30*24*60*60; // Approx a month of interval

  // We usually don't want to act every time cron runs (which could be every
  // minute) so keep a time for the next run in the site state.
  $next_execution = \Drupal::state()-&gt;get('cron_example.next_execution');
  $next_execution = !empty($next_execution) ? $next_execution : 0;
  if (REQUEST_TIME &gt;= $next_execution) {
    // This is a silly example of a cron job.
    // It just makes it obvious that the job has run without
    // making any changes to your database.
    \Drupal::logger('cron_example')-&gt;notice('cron_example ran');
    if (\Drupal::state()-&gt;get('cron_example_show_status_message')) {
      drupal_set_message(t('cron_example executed at %time', ['%time' =&gt; date_iso8601(REQUEST_TIME)]));
      \Drupal::state()-&gt;set('cron_example_show_status_message', FALSE);
    }
    \Drupal::state()-&gt;set('cron_example.next_execution', REQUEST_TIME + $interval);
  }
}


Also, for more fine-tuned approach, you can use the Ultimate Cron module, which provides more fine-grained control for the cron jobs.