Linux Crontab Command used to schedule script, to run repeatedly in the background at a set time.

preview_player
Показать описание
Crontab Command in Linux.

cron is one of the most useful tools in Unix or Linux.
crontab used to scheduling jobs or script, which will repeatedly run in the background at a set time.

crontab is a list of commands that you want to run on a regular schedule, and also the name of the command used to manage that list.
Crontab stands for “cron table” because it uses the job scheduler cron to execute tasks.

minute (0-59)
| Hour (0-23),
| | day of the month (1-31),
| | | month of the year (1-12),
| | | | day of the week (0-6 with 0=Sunday).
| | | | | commands

minute hour day/date month week commands/script name

1st *:minute (0-59)
2nd *:Hour (0-23)
3rd *:day/date of the month (1-31)
4th *:month of the year(1-12)
5th *:day of the week(0-6 0=sunday)

Field Description Allowed Value
MIN Minute field 0 to 59
HOUR Hour field 0 to 23
DOM Day of Month 1-31
MON Month field 1-12
DOW Day Of Week 0-6 ( 0=sunday)
CMD Command Any command to be executed.

crontab -e : To edit, change and create jobs in your crontab file.
crontab -l : It will display crontab list.
crontab -r : remove or erase all crontab jobs ( DO NOT USE)

minute hour day month week command

minute hour day month week command

minute hour day month week command

Scheduled crontab such way it should run on 1st of every month around 3:00 AM IST.

00 03 1 * * command/script name

Scheduled crontab to execute script on 2nd and 4th Saturday of every month around 9 am to 6PM.

Scheduled crontab to execute script on 2nd and 4th Monday and Friday of every month around 10am.

minute hour day month week command

minute hour day month week command

minute hour day month week command

minute hour day month week command

Scripts needs to run every 5 minutes on every Saturday

minute hour day month week command

minute hour day month week command

syntax:
or

------------------------------------------------------------------------------
crontab hash: Using Crontab -e here it's behaved like VI editor for Cron table.
:%s/^/####/g -- If there is any activity so we need to comment out all crontab entries so it will not trigger for that specific until activity is completed.
:%s/^####//g -- If activity is completed then we need to revert or enable crontab scheduled jobs to run.
--------------------------------------------------------------------------------
Рекомендации по теме