Is my VPS/Sever alive ?

 

Re: https://www.mql5.com/en/forum/136275/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.

 
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?
 
RaptorUK:

Re: https://www.mql5.com/en/forum/136275/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?
 
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
 
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 . . .
 
RaptorUK:

Re: https://www.mql5.com/en/forum/136275/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.