Scheduling is very useful when
you prefer do some automation jobs.
For scheduling the tasks in
Linux we are using at and crontab
Command
AT:
$ at – it is used to scheduled
one are more jobs (commands) for a single execution.
Example: $
at 10:30
$ at now+5 minutes
$ at tomorrow
$ at 10:30 july 15
2015
The
expression
|
Would
translate to
|
noon
|
12:00 PM October 18 2014
|
midnight
|
12:00 AM October 19 2014
|
teatime
|
4:00 PM October 18 2014
|
tomorrow
|
10:00 AM October 19 2014
|
noon tomorrow
|
12:00 PM October 19 2014
|
next week
|
10:00 AM October 25 2014
|
next monday
|
10:00 AM October 24 2014
|
fri
|
10:00 AM October 21 2014
|
NOV
|
10:00 AM November 18 2014
|
9:00 AM
|
9:00 AM October 19 2014
|
2:30 PM
|
2:30 PM October 18 2014
|
1430
|
2:30 PM October 18 2014
|
2:30 PM tomorrow
|
2:30 PM October 19 2014
|
2:30 PM next month
|
2:30 PM November 18 2014
|
2:30 PM Fri
|
2:30 PM October 21 2014
|
2:30 PM 10/21
|
2:30 PM October 21 2014
|
2:30 PM Oct 21
|
2:30 PM October 21 2014
|
2:30 PM 10/21/2014
|
2:30 PM October 21 2014
|
2:30 PM 21.10.14
|
2:30 PM October 21 2014
|
now + 30 minutes
|
10:30 AM October 18 2014
|
now + 1 hour
|
11:00 AM October 18 2014
|
now + 2 days
|
10:00 AM October 20 2014
|
4 PM + 2 days
|
4:00 PM October 20 2014
|
now + 3 weeks
|
10:00 AM November 8 2014
|
now + 4 months
|
10:00 AM February 18 2015
|
now + 5 years
|
10:00 AM October 18 2019
|
$ atq - is a command to see scheduled jobs
$ atrm <job number> – is
a command to remove the schedules jobs
CRONTAB: Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times. crontab if your name does not appear in the file /usr/lib/cron/cron.deny. If only cron.deny exists and is empty, all users can use crontab.
The 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.
Example: crontab
–e - to edit the jobs
crontab –l - to list the scheduled jobs
crontab –c –u
<user name> - to see particular user jobs
crontab –r - to remove crontab file
crontab format
# * * * * * command to execute
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ └───── day of week (0 - 6) (0 to 6
are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
# │ │ │ └────────── month (1 - 12)
# │ │ └─────────────── day of month (1 - 31)
# │ └──────────────────── hour (0 - 23)
# └───────────────────────── min (0 - 59)
This above example will send a mail yet every
5th 10th and 15th minute of every hour
No comments:
Post a Comment