title: How to open and output last 15 line from mysql log file via PHP?
body: <p>I want to open and read mysql error log file from my CentOS server. Is it possible to read and output last 15 lines of this file though PHP? <code>/var/lib/mysql/{SERVER_NAME}.err</code></p>
  
  <p>I have tried following</p>
  
  <pre><code>&lt;?php
  $file = '/var/lib/mysql/myserver_name.com.err';
  
  $filearray = file($file);
  $lastfifteenlines = array_slice($filearray,-15);
  var_dump($lastfifteenlines);
  ?&gt; 
  </code></pre>
  
  <p>But this shows</p>
  
  <blockquote>
    <p>Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 854157212 bytes) in /home/myserver_name/public_html/test.php on line 4</p>
  </blockquote>
  
  <p>Because the error log file size is almost 1GB. So how can I solve this problem? <strong>I need to check this mysql log file in every 5 min</strong></p>
  
  <p><em>My requirement is doing same as <code>chkservd</code> does in cPanel</em></p>