[英]Multiple Cron Jobs in 1 file (cPanel)
Im using worldweatheronline api for current weather temp for 150 cities 我使用worldweatheronline api为150个城市的当前天气温度
I need to update the temperature every 1 hour for every 150 cities, 我需要每150个城市每1小时更新一次温度,
My links to update this are like this 我更新此链接是这样的
mydomain.com/update/current.php?city=1
mydomain.com/update/current.php?city=2
...
mydomain.com/update/current.php?city=150
I think adding 150 cronjobs is not a good idea, also the limit for api calls is 3 calls for every second, so this can be a problem too. 我认为添加150个cronjobs不是一个好主意,api调用的限制是每秒3次调用,所以这也是一个问题。
I need your help on this, thank you. 我需要你的帮助,谢谢。
Why not 为什么不
#!/bin/bash
for X in 1 .. 150
do
mydomain.com/update/current.php?city=$X
done
For the cron job 对于cron工作
if the current.php
is specific for cron job. 如果
current.php
特定于cron作业。 (i think,it's a good idea to seperate cron jobs program from others). (我认为,从其他人那里分离cron job program是个好主意)。 just call it without parameter and do a loop for different
$city
inside the PHP program 只需在没有参数的情况下调用它,并在PHP程序中为不同的
$city
做一个循环
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.