首页 > 系统服务 > 详细

shell实现定时任务

时间:2021-01-05 20:58:19      阅读:23      评论:0      收藏:0      [点我收藏+]
 1 #!/bin/sh
 2 #功能:每天[8-18]点每5分钟执行一次
 3 #
 4 
 5 # 开始时间
 6 begin_time="800"
 7 # 结束时间
 8 end_time="1800"
 9 
10 while true
11 do
12     # 获取当前时间
13     now_time=`date "+%H%M"`
14     now_minu=`date "+%M"`
15     if [[ $now_time -ge $begin_time ]] && [[ $now_time -le $end_time ]] && [[ `expr $now_minu % 5` -eq 0 ]];then
16         echo "hello"
17     fi
18     # 每分钟检测一次
19     sleep 60
20 done

 

shell实现定时任务

原文:https://www.cnblogs.com/baoqinghe/p/14237443.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!