crontab设置定时任务脚本文件每秒运行一次,每个月最后一天的21点到22点 每20分钟(1200秒)执行一次

简介: crontab设置定时任务脚本文件每秒运行一次,每个月最后一天的21点到22点 每20分钟(1200秒)执行一次

每秒运行一次

#!/bin/bash
step=2
for((i=0;i<60;i=(i+step)));do
 php /home/www/tp6/think zhang
 sleep $step
done
exit 0

每个月最后一天的21点到22点 20分钟(1200)执行一次

#!/bin/bash
today=`date +%d`
hour=`date +%H`
last_day=`cal | xargs | awk '{print $NF}'`
if [ "$today" != "$last_day" ];then
        echo "today is not last day!"
         exit 1
 fi
 if [ "$hour" -ge 21 ] && [ "$hour" -lt 22 ] ;then
step=1200
for((i=0;i<3600;i=(i+step)));do
          php /www/wwwroot/otc-audit-develop/ think CopyNextMonthKPIi
          echo "hello world"
          sleep $step
  done
  exit 0
  fi
  echo "$hour not right"


目录
相关文章
|
1月前
|
存储 Linux Shell
Linux中的计划任务—Crontab调度一次性执行的任务at/batch
Linux中的计划任务—Crontab调度一次性执行的任务at/batch
136 0
|
Python Windows
Windows定时任务 每隔一段时间(最小到秒级)执行一次指定的Python脚本
Windows定时任务 每隔一段时间(最小到秒级)执行一次指定的Python脚本
Windows定时任务 每隔一段时间(最小到秒级)执行一次指定的Python脚本
Cron表达式范例:每隔5秒执行一次:*/5 * * * * ?
Cron表达式范例: 每隔5秒执行一次:*/5 * * * * ? 每隔1分钟执行一次:0 */1 * * * ? 每天23点执行一次:0 0 23 * * ? ...
5108 0
|
7月前
|
缓存
puppteer长时间运行定时清理缓存脚本
puppteer长时间运行定时清理缓存脚本
|
Java Linux
如何编写一个自动关闭某个进程的脚本,并使用cron定时执行?
如何编写一个自动关闭某个进程的脚本,并使用cron定时执行?
222 0
|
Linux Shell
centos 8利用crontab设置定时任务,crontab每秒运行
centos 8利用crontab设置定时任务,crontab每秒运行
776 0
centos 8利用crontab设置定时任务,crontab每秒运行
|
大数据 Python
Pythpn实现多脚本处理定时运行
Pythpn实现多脚本处理定时运行
118 0
Pythpn实现多脚本处理定时运行
crontab安装以及定时任务的执行
crontab安装以及定时任务的执行
119 0
|
SQL Shell Linux
如何用crontab每隔1分钟执行一个命令行脚本,shell设定时任务
如何用crontab每隔1分钟执行一个命令行脚本,shell设定时任务
771 0
如何用crontab每隔1分钟执行一个命令行脚本,shell设定时任务
|
监控 Shell 应用服务中间件
使用crontab配合shell脚本定时检测拉起服务
使用crontab配合shell脚本定时检测拉起服务
220 0