一、at at now +1 minutes // 一份钟后启动 at> date >/opt/ok at> ctrl +d at 04pm +3 days //三天后的下午四点钟启动 at>date
一、at
at now +1 minutes // 一份钟后启动
at> date >/opt/ok
at> ctrl +d
at 04pm +3 days //三天后的下午四点钟启动
at>date > /opt/ok
at>ctrl + d
执行结果
atd
at -l //列出at任务列表
atrm | at -d ID号 删除at任务列表
二 、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
每分钟:*/1 * * * * /bin/ls
每小时:* */1 * * * /bin/ls
每天的1点:* 1 * * * /bin/ls
每天的10,12,13-15 * 10,12,13-15 * * * /bin/ls
每周日00点 * 0 * * 0|7|sun /bin/ls
在/etc/crontab里面进行设置也是生效的只是需要加上用户名
crontab -e为当前登录用户添加计划任务
su root
crontab -e
*/1 * * * * echo " hello word" >> /opt/ok //每隔一秒将hello word 写入/opt/ok里
su user1
crontab -e
*/1 * * * * echo "hello friday" >> /opt/ok //每隔一秒将hello friday 写入/opt/ok 里面
crontab -l列出当前登录用户的计划任务
crontab相关目录
/etc/cron.d /etc/cron.monthly
/etc/cron.daily /etc/crontab
/etc/cron.deny /etc/cron.weekly
/etc/cron.hourly