How do I Create and Delete Cron Jobs/?


Cheap reseller Hosting


In this guide, you will find a technique to delete and create Cron jobs in cPanel and with Crontab. Check the two main ways to create and delete cron jobs:

1. Using cPanel:

cPanel is a web hosting control panel that allows you to manage your account. Most web hosting providers offer cPanel access. Here’s how to create and delete cron jobs using cPanel:

Creating a Cron Job:

  1. Log in to your cPanel account.
  2. In the “Advanced” section, click on the “Cron Jobs” icon.
  3. Under “Cron Email,” ensure a valid email address is entered to receive notifications about cron jobs.
  4. You can either choose a predefined schedule from the “Common Settings” dropdown menu or set a specific schedule using the individual time unit dropdown menus (Minute, Hour, Day, Month, Day of Week).
  5. In the “Command” field, enter the exact command you want to run at the scheduled time. This could be a script path or a specific command-line instruction.
  6. Click “Add New Cron Job” to save the cron job.

Deleting a Cron Job:

  1. Within the “Cron Jobs” section of cPanel, scroll down to “Current Cron Jobs.”
  2. Locate the cron job you want to delete.
  3. Under the “Actions” column, click “Delete.”

2. Using Crontab:

Crontab is a command-line utility for managing cron jobs on Linux/Unix systems. If you have direct access to the server shell, You can use crontab commands to create and delete cron jobs.

Creating a Cron Job:

  1. Open a terminal window.
  2. Use the following command to edit your crontab:

crontab -e

This command will open your crontab file in a text editor. Be cautious while editing the crontab file, as syntax errors can prevent cron jobs from running.

  • In the opened editor, add a new line with the cron expression followed by the command you want to run. The cron expression defines the schedule for the job.

For reference, you can find cron expression examples online https://www.ibm.com/docs/en/db2oc?topic=task-unix-cron-format

  • Save and close the editor.

Deleting a Cron Job:

  1. There are two ways to delete cron jobs using crontab:
  2. Delete all cron jobs:

crontab -r

  • Delete a specific cron job:

This method involves editing the crontab file and removing the specific line corresponding to the desired cron job. However, this might be not easy to identify for beginners. An alternative way is to:

  1. Use crontab -l to list all your cron jobs.
  2. Copy the remaining lines (excluding the one you want to delete) into a new file.
  3. Delete the old crontab using crontab -r
  4. Edit the new file containing the desired cron jobs (remove unnecessary lines).
  5. Use crontab – to install the new crontab containing the filtered jobs.

Remember, using crontab requires some familiarity with the command line and cron expressions. If you’re unsure, it’s recommended to use cPanel for managing cron jobs on your web hosting account.


Cheap web Hosting