Cron jobs are scheduled tasks that automatically run scripts or commands at defined times. They are useful for automating repetitive tasks like running maintenance scripts, sending reports, or backing up files. This guide explains how to create, edit, and manage cron jobs using cPanel.

 

What Is a Cron Job?

A cron job is a scheduled task that runs on the server at specified intervals. It can be used to:

  • Back up files or databases.

  • Run maintenance or update scripts.

  • Send automated emails or generate reports.

Cron jobs use a time-based format (called cron syntax) to determine when a command should run.

 

How to Create a Cron Job in cPanel

1. Log in to cPanel

  • Open your web browser and go to your cPanel login page, such as https://yourdomain.com/cpanel.

  • Enter your username and password.

  • Click Log in.

2. Open the Cron Jobs Tool

  • In the cPanel dashboard, go to the Advanced section.

  • Click Cron Jobs.

3. Set Up Email Notifications (Optional)

  • Under the Cron Email section, enter your email address if you want to receive notifications when a cron job runs.

  • Click Update Email to save.

4. Add a New Cron Job

1. Configure the Schedule

  • Use the Common Settings dropdown to choose a predefined interval (for example, Once Per Day, Every 5 Minutes).

  • Alternatively, set a custom schedule using the following fields:

    • Minute: 0–59

    • Hour: 0–23

    • Day: 1–31

    • Month: 1–12

    • Weekday: 0 (Sunday) to 6 (Saturday)

2. Set the Command

  • Enter the full command to run. Example:

    php /home/username/public_html/scripts/backup.php

  • Replace the path with the location of your script.

  • Click Add New Cron Job to save.

 

How to Manage Existing Cron Jobs

View or Edit Cron Jobs

  • Under Current Cron Jobs, you'll see a list of your scheduled tasks.

  • To make changes:

    • Click Edit next to a cron job.

    • Modify the timing or command.

    • Click Update to save changes.

Delete a Cron Job

  • Find the cron job you want to remove.

  • Click Delete next to it.

  • Confirm the deletion.

 

Tips for Using Cron Jobs

  • Test the command manually before scheduling it to ensure it works

  • Always use absolute paths (full path to your script or command)

  • Suppress unnecessary email notifications for frequent jobs by appending:

    /dev/null 2>&1

    Example:

    php /home/username/public_html/scripts/backup.php >/dev/null 2>&1



For additional help or to troubleshoot cron jobs, reach out to Lanetti support. We're here to make your automation easy!

Was this answer helpful? 0 Users Found This Useful (0 Votes)