user2361987
user2361987

Reputation: 25

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.

Upvotes: 0

Views: 501

Answers (2)

Amir
Amir

Reputation: 4111

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

Upvotes: 1

Ed Heal
Ed Heal

Reputation: 59987

Why not

#!/bin/bash

for X in 1 .. 150
do
    mydomain.com/update/current.php?city=$X
done

For the cron job

Upvotes: 1

Related Questions