侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

计划任务 at , crontab

2023-12-20 星期三 / 0 评论 / 0 点赞 / 119 阅读 / 2167 字

一、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

 

广告 广告

评论区