Skip to content

Instantly share code, notes, and snippets.

@kanikash4
Created November 28, 2017 17:22
Show Gist options
  • Save kanikash4/ce9fca680451bd1d4087e1a9a174ea94 to your computer and use it in GitHub Desktop.
Save kanikash4/ce9fca680451bd1d4087e1a9a174ea94 to your computer and use it in GitHub Desktop.
Linux crontab: [~]$crontab
crontab: command used to schedule and run tasks in the background at defined regular intervals.
Format:
* * * * * *
( MIN HOUR DOM MON DOW CMD )
where:
MIN- minute -0-59
HOUR-hour-0-23
DOM-Date of Month-1-31
MON- Month of year-1-12
DOW-Day of week-0-6
CMD-command- Any command to execute
After logging into the server, write command the below given command:
crontab -e
It will prompt you to edit thus edit/add your desired schedule for a file to be executed.
Few examples are mentioned below:
To execute a cron in every minute: * * * * * CMD
Example: * * * * * /path-of -file-to-be-executed
To execute a cron for particular time: (say every hour between 9 AM to 6 PM everyday)
Example: 0 9-18 * * * /path-of-file-to-be-executed
To execute a cron on particular day of the week:(say each monday at 10 AM and 6 PM)
Example: 0 10,18 * * Mon /path-of-the-file-to-be-executed
To execute a cron on particular date and time:(say Nov 15 at 10:15 AM)
Example: 15 10 15 11 * /path-of-the-file-to-be-executed
To execute a cron on every 10 minutes:
Example: */10 * * * * /path-of-the-file-to-be-executed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment