1. 一次性任务at
依赖于atd服务。
一段时间后执行(min、hours、days、months、years):
at now +2min
at now+2 min
at now+ 2min
at now+2min
明天下午5点执行:
at 5pm tomorrow
at 17:00 tomorrow
at 17:00 +1days
2025年10月24日上午9点执行:
at 9:00 2025-10-24
at 9:00 10/24/2025
立刻执行某脚本文件:
at -f file.sh now
查看计划任务:
atq
at -l
查看计划任务38的内容:
at -c 38
删除计划任务39:
atrm 39
at -r 39
at -d 39
2. 循环任务crontab
服务名称为crond。
查看crontab任务:
crontab -l
查看用户tom的crontab:
crontab -lu tom
创建任务:
crontab -e
为用户tom创建任务:
crontab -eu tom
清空crontab:
crontab -r
crontab -ru tom