作业调度:
crontab -e:(edit user's crontab)编辑
crontab -l:(list user's crontab)查看
先编写一个脚本test.sh,内容为 date;
[root@hadoop001 ~]# crontab -e
* * * * * /root/test.sh >> /root/test.log
格式:* * * * * *
第1个: 分
第2个: 小时
第3个: 日
第4个: 月
第5个: 周
*代表 每
用tail -F 来事实查看 test.log文件,发现每个1分钟就会输出日期。
如果是每10秒?
编写脚本:[root@hadoop001 ~]# vi test.sh
( #!/bin/bash
for((i=1;i<=6;i++));
do
date
sleep 10s
done
exit )
可以通过 tail -F test.log来时刻查看调度情况,会发现每隔10秒就会输出日期。
如果想定时一个脚本,在凌晨2点钟运行,该怎么做呢?
crontab -e 进入编辑:
0 2 * * * /root/test.sh >> /root/test.log