crontab每秒执行URL接口

首先crontab -e打开进行编辑

添加以下代码(默认为每秒执行一次脚本crontab.sh):

* * * * * /bin/sh /var/www/aa/crontab.sh

下面是/var/www/aa/crontab.sh脚本代码

#!/bin/bash

i=0;
step=2 #间隔的秒数,不能大于60
while [ $i -lt 60 ]
do
$(curl 'http://api-test-monitor.shanxinhui.com/user/test2/aa')
sleep $step
i=`expr $i + 2`
done

exit 0

原文地址:https://www.cnblogs.com/jiangzuo/p/6257598.html