View Categories

How to setup a CRON job

2 min read

Cron is a task scheduler built into the Linux operating system, allowing you to schedule automated tasks. cPanel provides a graphical interface to set up cron jobs easily.

Follow these steps to set up a CRON job:

  1. Log in to cPanel:
  • Access your cPanel account.
  1. Navigate to Cron Jobs:
  • In cPanel, go to Advanced > Cron Jobs.

 

 

  1. Configure Email Notifications (Optional):
  • You can specify an email address to receive notifications about your cron jobs.
  • Enter the desired email address in the top section and click Update Email.

 

 

  1. Add a Cron Job:
  • Scroll down to the “Add New Cron Job” section.

 

 

  • Choose the desired frequency for your cron job from the “Common Settings” dropdown or specify custom settings for Minute, Hour, Day, Month, and Weekday.
  • In the “Command” field, enter the command required to run the task. The format is usually <executable> <switches> <task command file>. For example:
/usr/bin/php -q /home/username/public_html/folder/task.php
  • /usr/bin/php is the path to the PHP executable.
  • -q is the ‘quiet’ switch.
  • /home/username/public_html/folder/task.php is the full path to the task command file.

 

  1. Editing or Deleting a Cron Job:
  • Active cron jobs will be listed in the “Current Cron Jobs” section at the bottom of the page.
  • You can edit or delete cron tasks here.
  • Click Edit to modify the time and task details, then click Edit Line to save your changes.
  • Click Delete to remove a cron task.

 

Additional Examples:

Running a wget command (for WordPress’s wp-cron.php):

Use wget to trigger WordPress’s wp-cron.php:

/usr/bin/wget -O /dev/null https://www.yourdomain.co.uk/wp-cron.php?doing_wp_cron
  • -O /dev/null sends any output to the Linux trash can.
  • Replace www.yourdomain.co.uk with your actual domain.

Running an executable script directly:

If the script has the correct shebang (e.g., #!/usr/local/bin/php) and permissions (usually chmod 755), you can run it directly:

/home/username/myscript.pl > /dev/null 2>&1
  • > /dev/null 2>&1 redirects all output to the Linux trash can.

 

Ensure your scripts have the necessary shebang and permissions for successful execution. The above examples provide flexibility for various types of cron jobs.

URGENT: Action Required for Domain and Email Services


If you currently have a domain, website, or email services hosted with us, please transfer them to a new provider as soon as possible.
Please note that all licenses have expired, and the server is scheduled for permanent shutdown imminently. Any data remaining on this server will be irretrievably lost once the server is turned off.
We strongly advise you to act promptly to ensure continuity of your services.
Thank you for your attention to this matter.

This will close in 0 seconds