Exploring Cron

Posted on by By Somen Sarkar, in Services, Software Testing | 0

Exploring Cron – II

In our previous blog, we have an overview of how to create a cron expression.

This blog will walk you through some solid example, which will help you to get a detailed understanding of crontab (Chronos tab or chronological table)

1. How do I see the current crontab entry?

A) From command prompt we need to fire the command

sudo crontab -l

2. How do I edit the entry of crontab?

A) -e switch of the cronttab will help you to edit the entries (default vi editor)

sudo crontab -e

3. How do I execute every minute?

A) * * * * * /path/to/your/script.sh

4. How do I execute every Saturday 2 AM?

A) 0 2 * * 6 /path/to/your/script.sh (Here 6 represent Sarturday and 2 represent the 2nd Hour i.e 2 AM

5. How do I execute a script every 20 minutes?

A) 0,20,40 * * * * /path/to/your/script.sh 

Keywords in Crontab entries.

@reboot     this will invoke to execute your script when the system startup
@yearly     this will run once in a year
@annually   this will invoke the script once in a year
@monthly    this will invoke the script once in a month
@weekly     this will invoke the script once in a week
@daily      this will invoke the script once in a day
@midnight   this will invoke the script daily
@hourly     this will invoke the script every hour
logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments