简体   繁体   中英

Multiple Cron Jobs in 1 file (cPanel)

Im using worldweatheronline api for current weather temp for 150 cities

I need to update the temperature every 1 hour for every 150 cities,

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.

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

if the current.php is specific for cron job. (i think,it's a good idea to seperate cron jobs program from others). just call it without parameter and do a loop for different $city inside the PHP program

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM