1. Home
  2. Crons
  3. Cron Tasks and Emails in N0C

Cron Tasks and Emails in N0C

Overview

Crons are programs that allow you to automatically execute scripts and commands at a given frequency on your site. For example, you can set up a Cron task to delete temporary files every week to free up disk space.

In this article, you will get familiar with viewing and managing your Cron tasks. If your Cron tasks produce a standard output (stdout), you will receive an email to an address that you can define.

Note : The PlanetHoster Glossary contains explanations on multiple topics and can be consulted to clarify certain terms.

Prerequisite

Go to https://mg.n0c.com/en/.

Tips

  • We advise you not to run a script every minute during the day, but rather at night.
  • If you receive too many emails from Cron tasks, you can disable this feature by adding this at the end of your task: >/dev/null 2>&1
  • If you have arguments to give to your script, you must not separate the argument from the file with a “?”. You just have to put a space.
  • If your script is causing runtime problems, then it would be better to call it via the php CLI in this form: 
php-cli -f /home/USERNAME/public_html/modules/cron.php argument=valeur >/dev/null 2>&1

How to Add and View Cron Tasks

  1. In N0C, go to Crons:
  1. Click on the Add button to open the Add Cron job window.
  2. Carefully read the examples in relation to the use:
  1. Choose the frequency of the Cron task in the COMMON PARAMETERS drop-down list:   
  1. Depending on the common setting chosen, enter all the necessary information using any of the drop-down lists MINUTE, HOUR, DAY OF THE MONTH, MONTH, and DAY OF THE WEEK:
  1. In ORDERED, give the full path from the root to the PHP script (strongly recommended). For example: php -q /home/planzujz/public_html/modules/cron.php >/dev/null 2>&1.
  2. Click on the SUBMIT button.
  3. The Cron is then displayed:
  1. Icons are available to Edit and Delete each Cron.
  2. The Search field is useful when you have several Crons and you want to filter them by keywords.

How to Set the Email Address

You need to define the address to which emails should be sent when your Cron tasks produce a standard output (stdout) such as an “echo” or a script error. To do this:

  1. Enter the EMAIL ADDRESS:
  1. Click on the Save button.
  2. If you wish to change the email address, click on the Delete button.
Updated on May 5, 2022