1、crontab命令

crontab [-u user] file #添加crontab
crontab -l #显示当前用户crontab文件
crontab -r #删除当前用户crontab文件
crontab -e #编辑当前用户crontab文件

2、 crontab文件格式

minute hour day month week commnd
*/1 * * * * service httpd restart #每分钟重启一次httpd服务
0 */1 * * * service httpd restart #每小时
30 21 * * * service httpd restart #每天21点30分
1 0 1-21 * service httpd restart #每月1-21日0点1分
1 0 * * 6 service httpd restart #每周六0点1分
Scroll to Top