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 use WHM cPanel to manage multiple website. So I will tell you two methods to create system cron jobs. One is through cPanel’s Cron Jobs function, the other is through command line.

1. Manage Cron Jobs Through cPanel Cron Jobs.

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

2. Manage Cron Jobs By Command Line.

  1. Login to your Linux server with SSH command.
  2. My Linux server is managed with cPanel, then I open a terminal by scroll down cPanel home page to ADVANCED area, then click Terminal icon to open a command line terminal.
    cpanel - advanced - cron jobs
  3. Run command crontab -l to list all current existing cron jobs.
    # crontab -l
    MAILTO="h******[email protected]"
    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 middle night ( 00:00 am ).
  10. Cron job time format 0 3 * * *  means the job command will be executed once per day at 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 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 hour.
  15. Cron job time format 0 0,12 * * * means the job command will be executed twice per day ( at start of one day and noon of one day ).
  16. Press esc, :, w, q key to save 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.