I have this script that i am trying to run with nohup ./RunReadMessages.sh
& and i am having problems with the messages being delayed, On one server this runs fine but if it's ran on more then one server it gets a big delay when it goes from message 3 back to message 1, Someone told me i should use threading could someone explan to me how i would do that with this script? Just a update: When i run this script by cron there is no delay, can someone tell me if it would be ok to run this script with cron and not nohup? I am not sure if the messags can catch up with running it as a cron job.
<?php
// File For checking messages version 1.0
define("INCLUDE_CHECK", true);
include "../classes/config_inc.php";
include_once('../classes/q3rcon.php');
mysql_connect("$db_host", "$db_user", "$db_pass") or die(mysql_error());
mysql_select_db("$db_database") or die(mysql_error());
$sql="SELECT * FROM {$db_prefix}_servers where Status='Online'";
$result = mysql_query($sql);
while ($data = mysql_fetch_assoc($result)) {
$svip = $data['ip'];
$svport = $data['port'];
$svrcon = $data['rconpass'];
$message1 = $data['message1'];
$message2 = $data['message2'];
$message3 = $data['message3'];
$r = new q3rcon("$svip", "$svport", "$svrcon");
$r->send_command ("say $message1");
sleep(30);
$r->send_command ("say $message2");
sleep(30);
$r->send_command ("say $message3");
sleep(30);
}
?>