新需求
- 我要定时,每天在3点的时候做时间同步;
知识点
- crontab 是linux中最常用的来定期执行程序的命令;
- ×基本格式,分 时 日 月 周
× × × × ×
| | | | |
| | | | +----- 星期中星期几 (0 - 7) (星期天 为0或7)
| | | +---------- 月份 (1 - 12)
| | +--------------- 一个月中的第几天 (1 - 31)
| +-------------------- 小时 (0 - 23)
+------------------------- 分钟 (0 - 59)
上手操作
#重要参数
-e 编辑
-l 查看
crontab -e
#create by test on 2020-08-05
* * * * * /usr/bin/ls ~/ >>~/ls.log
vi shell.sh
#!/bin/bash
ls -l
which sh
crontab -e
* * * * * /usr/bin/sh /root/shell.sh >~/ls.log
课程视屏
centos_base_lesson10 on bilibili
centos_base_lesson10 on xigua