How To Manage Cron Jobs In Linux Server Step By Step

In this article, I will show you how to create system real cron jobs in Linux. My Linux server is used to host my website and it uses WHM cPanel to manage multiple websites. So I will tell you two methods to create system cron jobs. One is through cPanel’s Cron Jobs function, the other is through the command line.

1. Manage Cron Jobs Through cPanel Cron Jobs.

  1. Login cPanel admin website, if you use WHM then you can open the cPanel website in WHM ( How To Open CPanel In WHM ).
  2. Scroll down the cPanel home page to the ADVANCED section, then click the Cron Jobs icon.
  3. In the following Add New Cron Jobs page, input a Cron Email and click the Update Email button to update it.
  4. Select cron job executes intervals in the Common Settings drop-down list. The list provides some commonly used job execution intervals. Then it will fill the job execution interval detail information below the Common Settings list.
  5. You should input the job execute script command in the Command input text box by yourself, this command script will be executed when the cron job is triggered.
  6. Click Add New Cron Job button to create it.
  7. Now you can see the cron job in the Current Cron Jobs list below Add New Cron Job area.
  8. You can edit it or delete it by clicking the link at the end of the cron job row.

2. Manage Cron Jobs By Command-Line.

  1. Login to your Linux server with the SSH command.
  2. My Linux server is managed with cPanel, then I open a terminal by scroll down the cPanel home page to the ADVANCED area, then click the Terminal icon to open a command-line terminal.
  3. Run command crontab -l to list all current existing cron jobs.
    # crontab -l
    MAILTO="h******g@gmail.com"
    SHELL="/bin/bash"
    0 0 * * * /usr/local/bin/php /home/abc/public_html/abc.php
  4. Run command crontab -e to enter edit crontab mode.
  5. Press o to enter insert mode, then you can insert or delete crontab content.
  6. You can add multiple cron jobs, one cron job in one line.
  7. The cron job line format is minute hour day month day_of_week job_command.
  8. The minute, hour, day, month and day_of_week value can be a number, multiple numbers (separate by ,) or *. If set it to * that means every minute, every hour, every day, every month, every day_of_week.
  9. Cron job time format 0 0 * * *  means the job command will be executed once per day at the middle night ( 00:00 am ).
  10. Cron job time format 0 3 * * *  means the job command will be executed once per day at the middle night ( 03:00 am ).
  11. Cron job time format */5 * * * * means the job command will be executed once per 5 minutes.
  12. Cron job time format 0,30 * * * * means the job command will be executed twice per hour ( at the start of an hour and half of an hour ).
  13. Cron job time format 0 * * * * means the job command will be executed once per hour.
  14. Cron job time format 0 */2 * * * means the job command will be executed once every two hours.
  15. Cron job time format 0 0,12 * * * means the job command will be executed twice per day ( at the start of one day and the noon of one day ).
  16. Press esc, :, w, q key to save the crontab changes.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.