I want to tail a dated log file LIVE on the administrator page of my website, but I'm running in to problems. I can get it to work only if I manually input the date in the $filename variable.
Here is the code I found on here too, but would like to know how to get dated files (ex: 2016_04_26.ilog).
<?php
$filename = 'date('Y_m_d').ilog';
$filedir = '/gamelogs/';
$output = shell_exec('exec tail -n250 ' . $filedir$filename');
echo str_replace(PHP_EOL, '<br />', $output);
?>
What is wrong with my code? Thanks in advance!
So after taking a break and coming back to the code, I realized I had the date format wrong and a couple other parts. Here is what I have that works!
<?php
$filename = date('y_m_d').'.ilog'; // misplaced quotes
$filedir = '/home/a3invmgr/destinedtobe/a3ilogs/'; // relative path instead of full path
$output = shell_exec("tail -n100 $filedir$filename"); //exec removed
echo str_replace(PHP_EOL, '<br />', $output); // line OK
?>