一:crontab进行定时任务设置

基本语法:

crontab [选项]

常用选项:

-e:编辑crontab定时任务

-l:查询crontab定时任务

-r:删除当前用户所有的crontab任务

service crond restart --重启任务调度

linux学习篇之crontab定时任务

crontab -e --进入文本编辑

*/1 * * * * ls -l /etc >> /opt/tmp/crontab.txt --前半段为任务调度时间设置 后面为需要执行的语句

crontab -l --查看任务调度

crontab -r --删除任务调度

linux学习篇之crontab定时任务

 

 

linux学习篇之crontab定时任务

二:使用crontab指定shell脚本

1.创建mytask.sh的shell脚本

2.mytask.sh的内容是date >> /opt/tmp/mydate

3.给mytask.sh赋予执行权限 chmod 744 mytask.sh

4.编辑定时任务 crontab -e

5.定时任务写入一分钟执行一次脚本 */1 * * * * /opt/tmp/mytask.sh

 

 

 

 

 

 

 

 

 

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2021-12-18
  • 2022-02-17
  • 2021-08-13
  • 2021-09-04
  • 2021-12-21
猜你喜欢
  • 2022-01-29
  • 2022-12-23
  • 2021-04-10
  • 2021-06-21
  • 2021-05-30
  • 2022-02-04
相关资源
相似解决方案