Cron setup for Appt reminder

openemrdev wrote on Thursday, January 10, 2013:

Gents,
            How can i run this cron job across multiple sites

http://www.open-emr.org/wiki/index.php/Sms_and_Email_Notification_Howtos

As well how can i measure the cron job performance while  i am having multiple databases.I guess it affect server performance.

Please address me.

Thanks,
John

bradymiller wrote on Saturday, January 12, 2013:

Hi,

The command line scripts need to be updated to support multiple sites. Probably best mechanism is to bring the site in as a parameter (default to ‘default’) and then set this to the $_GET = ‘default’; value. Then it should work. Here’s some more info on the topic:
http://www.open-emr.org/wiki/index.php/Active_Projects#Command_Line_PHP_Scripts
http://sourceforge.net/projects/openemr/forums/forum/202505/topic/3514602

Just need to get somebody (volunteer or hire) somebody to do the work.
-brady
OpenEMR

openemrdev wrote on Saturday, January 12, 2013:

Brady,
            Thanks for your responses.

Here is the code i tried,Please have a look at once  and let me guide,if any issues on this code.I don’t have enough time to submit this on github. please don’t mistake me

$OE_SITES_BASE = "../../sites";
$dh = opendir($OE_SITES_BASE);
//echo $dh;
if (!$dh) die("Cannot read directory '$OE_SITES_BASE'.");
$siteslist = array();
while (false !== ($sfname = readdir($dh))) {
  if (substr($sfname, 0, 1) == '.') continue;
  if ($sfname == 'CVS'            ) continue;
  $sitedir = "$OE_SITES_BASE/$sfname";
  if (!is_dir($sitedir)               ) continue;
  if (!is_file("$sitedir/sqlconf.php")) continue;
  $siteslist[] = $sfname;
  
    }
     
closedir($dh);
ksort($siteslist);
if($_GET['site']!='')
{
//cron_email_notification.php code 
}
$total_sites=count($siteslist);
$numeral=$_GET['numeral']; //used to nesting the loop
if($total_sites>$numeral)
{
if($numeral=='')
$numeral=0;
else
$numeral++;
//stop incremental looping redirection while the number of sites and the current site is equal
if($total_sites==$numeral)
{
die;
}
//next site url for redirection
$url="/cron_email_notification.php?site=".$siteslist[$numeral]."&numeral=".$numeral;
//header in php throws unexpected break somewhere. it caused to go through javascript
?>
<script language="Javascript">
location.href="<?php echo $url; ?>";
</script>
<?php
}

Thanks

openemrdev wrote on Saturday, January 12, 2013:

Brady,
          When we run cron_email_notification.php from cron job,it collects all sites from openemr/sites folder then it sends the reminders to all patient one by one site

Here is simple scenario

site one(Send all reminders) => Site2 (Send all reminders) => Site3 (Send all reminders)

Thanks

openemrdev wrote on Tuesday, January 15, 2013:

Brady,
            Could you please check this and give me your comments

Thanks

bradymiller wrote on Tuesday, January 15, 2013:

Hi John,

Does it work?
My initial thoughts are that we should have a generic method within the php command line scripts for OpenEMR that do the following by utilizing a parameter when calling the script:
1. If no parameter is entered, then set $_GET to ‘default’
2. If the ‘ALL_SITES’ parameter is given, then do what you are doing and cycle through them all
3. If a site name is given as a parameter, then only do that site

If we had a mechanism like that, then we’d have a nice generic way to support command line scripts.

-brady
OpenEMR

bradymiller wrote on Tuesday, January 15, 2013:

Hi,

To take this further, I think I’d do the following:
1. For the command line scripts, simply support a parameter that brings the site in (so if no parameter, use ‘default’ and if a parameter then set this to the site).
2. Then I’d make a script called multsite_process_scripts which takes one parameter, which is the script names (ie. the scripts in number one above).This script could then iterate through all the different sites and run the above script for each. This script would be a general purpose script that could be used on any of the other command line scripts.

-brady
OpenEMR

openemrdev wrote on Tuesday, January 15, 2013:

Brady,
           Yes it works good,but i did only minimal tests

Any timeline  for your multiprocess_setup.php,How may i help you on this,please let me know

Thanks,

bradymiller wrote on Tuesday, January 15, 2013:

Hi,

No time for me to do this(I’m just a volunteer with limited resources), but I’m glad to provide feedback/guidance/testing if you choose to work on this(another option is hiring a pro). The first step is getting a github repo going; here’s a tutorial on setting this up: http://www.open-emr.org/wiki/index.php/Git_for_dummies

-brady
OpenEMR

chriskuhar wrote on Wednesday, October 23, 2013:

with the current script (4.1.2), here is a low budget way for cron to work by site:

* */1 * * * wget https://emr.mysite.com/modules/sms_email_reminder/cron_sms_notification.php?site=mysite
* */1 * * * wget https://emr.mysite.com/modules/sms_email_reminder/cron_email_notification.php?site=mysite

of course apache will have to be modified to allow access to this directory. Some folks might want to require a key, MD5 hash for example,

?site=mysite&access=131e1b84fa37007c07de0b8fbd611dac

where the key could be put in the site config file, and checked only in the cron scripts.