Cron Setup through Cpanel and Linux command

What is Cron

Cron which is also known as Cron Job its basically a script that has some piece of code which is executed independently on server on scheduled time. Any command or script runs repeatedly based on scheduled time. The Cron daemon runs as a background service on server to check whether any cron job is scheduled on that particular time or not. Cron Job entries are made on /etc/crontab file.

 

How to setup Cron

Threre are two way to setup the Cron

i) Cron Setup through Cpanel

ii) Cron Setup through Command line

i) Cron Setup through Cpanel

Under “Advance” tab you will see “Cron Jobs” section.

Cron Jobs

Just need to click on this above icon to setup the cron. You can setup cron with this

Cron Jobs

ii) Cron Setup through Command line

Add/Edit CronJobs through Command line

On your command prompt you need to write below command

crontab -e

Syntax of Contab Field Description

1 2 3 4 5 /path to command argument 1 arguement2

Where,

  • 1: Minute (0-59)

  • 2: Hours (0-23)

  • 3: Day (0-31)

  • 4: Month (0-12 [12 == December])

  • 5: Day of the week(0-7 [7 or 0 == sunday])

  • /path/to/Script – Script or command name to schedule

Easy to remember :

* * * * * Script path name
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)
The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video Conferencing and social media domain. The motive of creating cutehits was just to share the knowledge/solutions I get to know during my day to day life so that if possible I can help someone for same problems/solutions. CuteHits.com is a really a very effort for sharing knowledge to rest of the world. For any query/suggestion about same you can contact me on below details:- Email: shekharmca2005 at gmail.com Phone: +91-9560201363

Latest posts by Chandra Shekhar (see all)

You may also like...