Why do I Receive Cron Emails?

Email alerts are triggered for errors generated by server-side cron. The subject of these emails reveals the command executed, and the email contains the output of the cron job(s). These emails are intended for a technical person and are sent to the Technical Contact of your Bolt if one is assigned. If your Bolt does not have a Technical Contact assigned, the emails are sent to the owner of the Bolt. Additionally, the output from cron jobs are logged in the ~/logs/cronlog file.

What do these emails signify?

Cron jobs are designed to operate silently without generating any output. If you start receiving cron emails, it can indicate that an error has occurred during the execution of the cron job. These emails serve as alerts to notify you of potential issues that require attention. It’s important to note that the cron error emails can become excessive when something goes wrong because cron is often configured to run every 5 minutes.

These are some of the most common causes of cron emails:

One common issue is to have an extra space or line break at the end of a theme functions.php file or the wp-config.php file. This can be fixed by removing the closing PHP tag and any additional spaces and line breaks.

For example, the following example is wrong:

function somefunction() {
  return TRUE;
}
?>

The correct way to end a PHP file is like the following, without the last closing tag and extra space and line breaks:

function somefunction() {
  return TRUE;
}

Additional common causes of cron emails include:

  • Script errors: Errors within the scripts executed by cron jobs, such as syntax, logic, or runtime errors, can trigger notifications. Review the scripts for potential issues.
  • Syntax errors: Typos, missing arguments, or incorrect paths in the cron job command itself can cause the job to fail and generate an error message.
  • Scheduling conflicts: Scheduling multiple cron jobs to run simultaneously can lead to conflicts and job failures, resulting in cron emails. Review your cron job scheduling to ensure conflicts are minimised.

Servebolt Control Panel cron options

Active

This is the default option when you add a cron job to the Servebolt Control Panel. All cron jobs with output will send an email letting you know the output of the given cron job.

Active (silent)

The ‘Active (silent)’ option turns off email notifications and will only send emails regarding cron jobs if the cron job that was executed ran into an error. To eliminate these emails you’ll need to fix the underlying errors.

If you don’t need email notifications for when cron jobs have been executed, you can select the cron job and choose “Do not send email” in the drop-down box below. Click the “Update” button at the bottom of the page to save changes.

The cause of the cron emails can vary, and it is always important to check the ErrorLog if you receive a large volume of cron emails.


Should you have any additional questions please don’t hesitate to contact our support chat at servebolt.com!