About Cron jobs

Cron jobs in cPanel allow you to automate tasks and execute commands or scripts on your website at scheduled intervals. This can be useful for a variety of administrative tasks, such as clearing temporary files, sending regular reports, or executing database backups. The cron job feature helps you automate processes without manual intervention, ensuring that tasks run on time.

1. Accessing Cron Jobs

To access the Cron Jobs feature:

  1. Log in to your cPanel account.
  2. Navigate to the Advanced section.
  3. Click on Cron Jobs.
    Screenshot 2025-03-04 015500.png

This will open the Cron Jobs interface where you can set up, manage, and monitor automated tasks for your site.

Understanding Cron Jobs

Cron jobs are scheduled tasks that run automatically at specified intervals. You can define the frequency and the exact time when these tasks should be executed. Cron jobs are typically used for running commands, executing scripts, or performing server maintenance tasks at specific times.

How Cron Jobs Work

Cron jobs are scheduled by defining time intervals using five fields:

For example, if you want a script to run at 2:00 AM every day, you would enter:

Common Settings for Cron Jobs

2. Adding a New Cron Job

To add a new cron job, follow these steps:

  1. Email Settings:

    • If you want an email sent to you every time the cron job runs, enter your email address in the Current Email section. For example, you may see newsite@example.com in this field.
    • If you don’t want to receive emails, use the command >/dev/null 2>&1 to suppress email notifications. For example:
      /usr/local/bin/php /home/newsite/public_html/path/to/cron/script >/dev/null 2>&1
      image.png
  2. Set the Time Intervals:

    • Use the dropdown menus for Minute, Hour, Day, Month, and Weekday to specify when the cron job should run.
      image.png
  3. Command:

    • In the Command field, you’ll enter the command or script that you want to run. Below are some common examples:

    General PHP Command:

    swift
    /usr/local/bin/php /home/newsite/public_html/path/to/cron/script

    This will run a PHP script located at /home/newsite/public_html/path/to/cron/script.

    Domain-Specific PHP Command:

    swift
    /usr/local/bin/ea-php99 /home/newsite/domain_path/path/to/cron/script

    In this example, replace ea-php99 with the PHP version assigned to the domain. To find the PHP version assigned to the domain, you can check in the MultiPHP Manager in cPanel.

  4. Add the Cron Job: Once you have configured the cron job settings, click Add New Cron Job to schedule the task.

Cron Job Email Notifications

3. Managing Cron Jobs

Once you have set up cron jobs, they will appear in the Current Cron Jobs table.
image.png
This table displays the following information:

Minute Hour Day Month Weekday Command Actions
* 2 * * * /usr/local/bin/php /home/newsite/public_html/path/to/cron/script [Edit] [Delete]
Important Notes About Cron Jobs

Cron jobs are an invaluable tool for automating tasks on your website. By setting up cron jobs, you can ensure that tasks like cleaning temporary files, backing up databases, and running scripts happen automatically and on schedule. Always verify your commands and test scripts before scheduling them, and be mindful of your email notifications to keep track of your cron job activities.


Revision #2
Created 4 March 2025 07:54:37 by Admin
Updated 4 March 2025 08:12:25 by Admin