Is there a way I can have one cron run every 15 minutes instead of 2 crons doing the same job because I have 2 identical scripts running side by side on the same server (BUT update 2 different databases at the same time) I'm going to clarify what I mean. 1st cron (updates a config_name.php file located at public_html/Script1/config_name.php 2nd cron (updates a config_name.php file located at public_html/Script2/config_name.php Both scripts are the same and it updates 2 different databases which are identical in setup. So my question is there a way I can have the 1st cron update both script 1 and script 2's databases with just the one cron? If so, how would the coding look. Do I just include a second include("/public_html/Script2/config_name.php"); below the first one? Is it that simple? I have posted the cron file below. <? include("/public_html/Script1/config_name.php"); $round = mysql_fetch_array(mysql_query("SELECT id FROM rounds ORDER by id DESC LIMIT 1;")); if(($round) || ($time > $round['starts'])){ mysql_query("UPDATE rounds SET lastran30min='$time' WHERE id='$round[id]';"); mysql_query("UPDATE player_trained SET unit1=0, unit2=0, unit3=0, unit4=0, unit5=0, unit6=0, unit7=0, unit8=0, unit9=0, unit10=0 WHERE unit1>0 OR unit2>0 OR unit3>0 OR unit4>0 OR unit5>0 OR unit6>0 OR unit7>0 OR unit8>0 OR unit9>0 OR unit10>0;"); } die(); ?>
Hi premiumscripts, thanks for taking the time to help me. I don't think that will work because it will still execute both crons, I'm trying to cut down the number of crons it runs because hostgator is telling me that I have too many running at the 30 mins interval so on occasion, the the server has missed executing the 30mins crons from time to time. I'm just hoping on running 1 cron to do both jobs. Any ideas?
Well that will cut down the nr of crons (you will only need one that points to that file). Since there are 2 DBs that need updating there is no way you can simply reduce your code.
I'm not so much worried about reducing the code. My primary goal is to reduce the number of crons. So if I follow the method you suggested, <?php require 'cron1.php'; require 'cron2.php'; ?> Where exactly do I put that code? Not in the cron file I mentioned above right? Or in the script itself?
Well you can just copy the code from the other one n that file.. or do a require 'cron2.php' in that one. And then remove the cronjob for it. The code I gave would be in a new file. You would then create a cron job for it and remove the 2 other cron jobs. Thus reducing the nr of cronjobs. (You would need the full path to the php files in the require statements though)