Answers.Body: <h3>CronPlus Extension</h3>
  <p>Take a look at the <a href="https://lab.civicrm.org/extensions/cronplus" rel="nofollow noreferrer">CronPlus extension</a> to execute tasks in more accurate way and this <a href="https://civicrm.stackexchange.com/questions/12003/has-anyone-run-into-scheduled-jobs-drifting-on-centos7">SE question</a>.</p>
  <p>Alternatively, you could setup a cron task and script to do this like below:</p>
  <h3>Cron task</h3>
  <pre><code>0 17 * * * su www-data -s /bin/bash -c &quot;/home/example/cronscripts/send_daily_reports.sh&quot;
  </code></pre>
  <p>The <code>send_daily_reports.sh</code> file.</p>
  <pre><code># 7 A Report title
  # 8 Another Report title
  for rept in 7 8
  do
   
      /usr/bin/php /usr/local/bin/wp --user=civicron --url=https://example.org --require=/var/www/example/wp-content/plugins/civicrm/wp-cli/civicrm.php --path=/var/www/example civicrm api Job.mail_report instanceId=${rept} format=csv --allow-root  &gt; /dev/null 2&gt;&amp;1
  
  done
  </code></pre>
  <p>One benefit of using the CLI cron task approach is that in the scheduled jobs UI, my experience is multiple reports cannot send at the same time, even if you have multiple jobs created.</p>
  <p><strong>Update 3/20/2024</strong>: As of 5.71.1 and likely much earlier, creating multiple &quot;mail_report&quot; jobs works OK now.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-31T07:13:20.110Z
Answers.Text: Thanks, Andy. I thought I'd heard of this problem before but oddly searching didn't find anything.
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-31T08:06:02.710Z
Answers.Text: I was too hasty to check that as an answer - the extension has an issue which seems to be terminal at present.
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-24T05:47:27.780Z
Answers.Text: Noting the issue with detailed logging for plus: https://lab.civicrm.org/extensions/cronplus/-/issues/8#note_91064. I added an alternative method with a cron task at CLI.
Answers.UserDisplayName: Andy Burns
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-30T17:16:07.660Z
Answers.LastActivityDate: 2024-03-20T12:33:44.527Z
Answers.LastEditDate: 2024-03-20T12:33:44.527Z
Answers.UserDisplayName: Andy Burns
Body: <p>The facility to email reports using scheduled tasks is good and works.  However we'd like to email a report at 5pm each day. Having started this task to run after 4:59 on a certain day it is now slipping every few days to a later time.  We run cron every 15 minutes so a week ago it ran at 5pm, and it's now slipped to 5:30pm in one week.  Is there a way to email a report at a fixed time each day?- A few minutes difference doesn't matter.  I don't think 'Scheduled Reminders' can do this as it needs some kind of trigger.</p>
  
Tags: <cron><mailing><scheduled-reminders>
Title: Mailing a report at the same time - how?
ThreadText: # Mailing a report at the same time - how?
  
  (Asked by: username_0 on 2023-05-30)
  
  The facility to email reports using scheduled tasks is good and works. However we'd like to email a report at 5pm each day. Having started this task to run after 4:59 on a certain day it is now slipping every few days to a later time. We run cron every 15 minutes so a week ago it ran at 5pm, and it's now slipped to 5:30pm in one week. Is there a way to email a report at a fixed time each day?- A few minutes difference doesn't matter. I don't think 'Scheduled Reminders' can do this as it needs some kind of trigger.
  
  **Tags:** cron, mailing, scheduled-reminders
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-05-30. Score: 2
  
  ### CronPlus Extension
  
  Take a look at the [CronPlus extension](https://lab.civicrm.org/extensions/cronplus) to execute tasks in more accurate way and this [SE question](https://civicrm.stackexchange.com/questions/12003/has-anyone-run-into-scheduled-jobs-drifting-on-centos7).
  
  Alternatively, you could setup a cron task and script to do this like below:
  
  ### Cron task
  
  ```
  0 17 * * * su www-data -s /bin/bash -c "/home/example/cronscripts/send_daily_reports.sh"
  
  ```
  
  The `send_daily_reports.sh` file.
  
  ```
  # 7 A Report title
  # 8 Another Report title
  for rept in 7 8
  do
   
      /usr/bin/php /usr/local/bin/wp --user=civicron --url=https://example.org --require=/var/www/example/wp-content/plugins/civicrm/wp-cli/civicrm.php --path=/var/www/example civicrm api Job.mail_report instanceId=${rept} format=csv --allow-root  > /dev/null 2>&1
  
  done
  
  ```
  
  One benefit of using the CLI cron task approach is that in the scheduled jobs UI, my experience is multiple reports cannot send at the same time, even if you have multiple jobs created.
  
  **Update 3/20/2024**: As of 5.71.1 and likely much earlier, creating multiple "mail\_report" jobs works OK now.
  
  > **Comments:**
  > **username_0**: Thanks, username_0. I thought I'd heard of this problem before but oddly searching didn't find anything.  
  > **username_0**: I was too hasty to check that as an answer - the extension has an issue which seems to be terminal at present.  
  > **username_1**: Noting the issue with detailed logging for plus: https://lab.civicrm.org/extensions/cronplus/-/issues/8#note_91064. I added an alternative method with a cron task at CLI.  
  
  ---
  
  