crontab 定时任务
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
*/5 * * * * bash脚本名 每5分钟执行
0 2 * * * bash脚本名 每天凌晨2点执行
0 2 7 * * bash脚本名 每月7号凌晨2点执行
注: day of month + month 与 day of week 不同时使用
crontab命令:
-l: 显示当前用户的任务列表
-l -u username 显示其它用户的任务列表
-e:编辑任务
-r: 移除所有任务
练习.