Is my VPS/Sever alive ?

Back to topics list To post a new topic, please log in or register
avatar
14167
RaptorUK 2011.12.03 13:29
 

Re: https://forum.mql4.com/44179/page3#532562

I got my php working as a Cron job. I created a simple EA to send the file via FTP and set the Cron job (I use cPanel based hosting) to run every 2 mins.

The php . . .

<?php
$to = "your@email.com";
$subject = "EA is silent";
$body = "EA has stopped responding . . . ";
$minutes = 3;               // max allowable age of file in mins
$file = '/home/crum/public_html/ea/cron.txt';
$filetime = filemtime($file);
$max_age = time()-($minutes * 60); // max age of file in seconds since Jan 1970
// print "File: $file  Filetime: $filetime  twomins:  $timetwomins";

if ($filetime < $max_age && ( ( date(w) > 0 && date(w) < 5 ) || ( date(w) == 5 && date(G) < 22 ) || ( date(w) == 0 && date(G) > 22 ) ) ) {
   mail($to, $subject, $body);
}
?>

The EA

//+------------------------------------------------------------------+
//|                                                   TestCron.mq4   |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

extern int FTPFrequency = 2;  //every x minutes send the file via FTP

int init()
  {
   
   return(0);
  }

int deinit()
  {

   return(0);
  }

int start()
   {
   static datetime LastTimeSent = 0;
   
   if (TimeCurrent() > LastTimeSent + (PERIOD_M1 * 60 * FTPFrequency))
      {
      SendFTP("cron.txt");
      LastTimeSent = TimeCurrent();
      }

   return(0);
   }

It's all a little rough round the edges, I will make the php a little more configurable so it's easier to use with different time zones . . . but it works so far.

 
avatar
137
PlanandTrade 2013.09.21 11:27 #
 
With your Idea its maybe possible to find out that a timeout error have happen, but the MetaTrader must be restart when a timeout error happen, how can i let the MetaTrader to be restart automatic when i am not at home and the timeout error have happen?
 
avatar
2178
tonny 2013.11.03 21:07 #
 
RaptorUK:

Re: https://forum.mql4.com/44179/page3#532562

I got my php working as a Cron job. I created a simple EA to send the file via FTP and set the Cron job (I use cPanel based hosting) to run every 2 mins.

The php . . .

The EA

It's all a little rough round the edges, I will make the php a little more configurable so it's easier to use with different time zones . . . but it works so far.

I noticed you mentioned php. What is the easiest way for a ea to send data to a php web app like say ea sends data to server then via a php app this data is redistributed or displayed?
avatar
127
tintin92 2013.11.03 22:47 #
 
MetaTrader send a file to your website with the SendFTP bool (string filename, string ftp_path = NULL)
You have to configure your website with a cron that periodically execute the PHP script.

Do a Google search : php cron
avatar
14167
RaptorUK 2013.11.03 23:39 #
 
tonny:
I noticed you mentioned php. What is the easiest way for a ea to send data to a php web app like say ea sends data to server then via a php app this data is redistributed or displayed?
No idea, the only php I know is the bit I researched for this little project . . .

avatar
127
tintin92 2015.01.11 22:21 #
 
RaptorUK:

Re: https://forum.mql4.com/44179/page3#532562

I got my php working as a Cron job. I created a simple EA to send the file via FTP and set the Cron job (I use cPanel based hosting) to run every 2 mins.

The php . . .

The EA

It's all a little rough round the edges, I will make the php a little more configurable so it's easier to use with different time zones . . . but it works so far.

Hi,

Nothing new since 2011 ?

Can we add to send SMS ?

With my web hosting I can only run a cron one time / hour. 

Back to topics list  

To add comments, please log in or register