Task Schedule:
1, at some point in the future to perform a task at a time;
At specified time execution
Batch idle time execution
At time
At>command
At>ctrl+d
Specify time:
Absolute time: hh:mm, DD. Mm. YY Mm/dd/yy
Relative Time: now+#
Units: Minutes,hours, days, weeks
Blur Time: Noon, midnight, teatime
Execution result of the command: sent to the user who scheduled the task in the form of a message
[Email protected] tmp]# at Now+1min
At> ls/tmp
at> <EOT> # Press CTL + D
Job 2 at 2016-12-02 17:17
[Email protected] tmp]# at-l equivalent to ATQ
3 2016-12-02 17:17 a root
[Email protected] tmp]# at-d equivalent to ATRM
3 2016-12-02 17:17 a root
2. Perform a task periodically;
cron life
Linux has a command that can perform system tasks on a regular basis. This is the Crond service.
1. Command format:
cron [Options] [file]
Crontab-l//List all current Scheduled tasks
Crontab-l-u JP//List all scheduling tasks for user JP
Crontab-r//Delete all task scheduling work
Crontab-e
Minute Hour Day Month Dayofweek command
Minutes hours days months days per week order
Minute The first few minutes of every hour to perform the task
Hour the first few hours of the day to perform this task
Day of the month to perform the task
Month months of the year to perform this task
DayOfWeek The day of the week to perform the task
2. Command function:
cron: Self is a service that runs uninterruptedservice crond {start|stop|restart|reload|status}
Anacron :cron Supplement that allows Cron to perform a task that has not been performed in the past time for various reasons during the resumption of normal execution once
System Cron Task:
/etc/crontab
Minutes hours Day Month Week user tasks
User Cron Task:
/var/spool/cron/username
Minutes Hours Day Month Week task
Valid values for TIME:
Minutes: 0-59 Hours: 0-23 days: January-3 January: 1-12 weeks: 0-7,0 and 7 denote Sunday
Time-Pass representation:
* All valid values for the corresponding time
3 * * * *
3 * * * 7
13 12 6 7 *
, discrete point of time: 10,40 02 * * 2,5
- continuous point of time: 10 02 * 1-5
/# corresponds to the range of values per how often: */3 * * * *
5 * * * * ls
//指定每小时的第5分钟执行一次ls命令
30 5 * * * ls
//指定每天5:30执行一次执行ls命令
40 7 18 * * ls
//指定每月18号的7:40分执行ls命令
30 5 18 6 * ls
//指定每年的6月18日5:30执行ls命令
50 6 * * 0 ls
//每星期日的6:50执行ls命令 [可用英文表示,sun表示星期天,mon星期一]
30 3 10,20 * * ls
//每月10号及20号的3:30执行ls命令 [“,”连接多个不连续的时段 ]
25 8-11 * * * ls
//每天8-11点的第25分钟执行ls命令 [“-”连接连续的时段 ]
*/15 * * * * ls //每15分钟执行一次[即每个小时的第0 15 30 45 60分钟执行ls命令]
0 */7 * * * ls
//指定每7小时执行一次
ls命令[即每天的第0 7 14 21点整执行ls命令]
* */7 * * * ls
//每天7小时执行一次
ls命令[即每天的第0 7 14 21点的一小时中的每分钟]
30 6 */10 * * ls //每月每隔10天6:30执行一次ls命令[每月的1、11、21、31日的6:30]
Every day 7:55 executes all executables in the/etc/cron.daily directory as root
55 7 * * * root run-parts /etc/cron.daily
//[红色表示执行后面目录中的所有可执行文件]
Executes once every two hours: 08 */2 * * *
Execute once every two days: 10 04 */2 * *
The execution results are sent to the administrator as a message: command to absolute path
*/3 * * * * /bin/cat/etc/fstab > /dev/null # Normal results clear, error results still send mail
*/3 * * * */bin/cat/etc/fstab &> /dev/null # All results cleared
CRON environment variable: Cron executes all commands to go down the path specified by the PATH environment variable
#!/bin/bash
Path/bin:/sbin:/usr/bin:/usr/sbin # Defining the PATH environment variable
# If you remove the parameter Rum-parts, you can write a script name to run, not the folder name.
* * * * * Root run-parts/etc/cron.hourly
4 * * * Root run-parts/etc/cron.daily
4 * * 0 root run-parts/etc/cron.weekly
4 1 * * Root run-parts/etc/cron.monthly
[[email protected] etc]# ls cron*
Cron.deny crontab
CRON.D:
0hourly Sysstat
Cron.daily:
Logrotate Makewhatis.cron Mlocate.cron prelink Readahead.cron tmpwatch
Cron.hourly:
0anacron Mcelog.cron
Cron.monthly:
Readahead-monthly.cron
Cron.weekly:
99-raid-check
[[email protected] etc]# ls /var/spool/cron/
Hadoop
---end---
Linux commands: Task Scheduler Cron,at,batch