Reputation: 1805
I have two web servers namely web1 and web2. They are identical servers. Now, I have a php script that needs to run every 30 minutes. How can I run the php script in alternately every 30 minutes. Let say after 30 minutes from web1 server, the next 30 minutes will be run to web2 server.
This is wrong.
web1:
*/30 * * * * /usr/bin/php /path/to/site/cron.php
web2:
*/30 * * * * /usr/bin/php /path/to/site/cron.php
Thanks.
Upvotes: 0
Views: 1442
Reputation: 29266
Either put the smarts in your script and just trigger the script every 30 mins
(e.g. save a file telling it which server it ran on last time)
OR
Run on web1 when the minute is 00, run on web2 when the minute is 30.
# min hr dom moy dow
0 * * * * web1
30 * * * * web2
Upvotes: 2
Reputation: 951
Schedule it manually on each web server to run every 1 hour i.e. schedule your cron on web1 to run at 00:00 , 01:00 , 02:00 ..... 23:00 and your cron on web2 to run at 00:30 , 01:30 , 02:30 ......23:30 ( You need to put manual entry for each run )
Upvotes: 0