0

It's working when i move the file to app current directory

$cmd = 'grep "Finished" sync.log | tail -n1;';
$exe = shell_exec($cmd);
error_log($exe);

Output:

I, [2020-01-27]  INFO -- : Finished

but when i try to specified the direcotry, it doesn't work

$cmd = 'grep "Finished" /var/log/sync.log | tail -n1;';
$exe = shell_exec($cmd);
error_log($exe);

Edit Found this https://www.linode.com/community/questions/18703/getting-error-failed-to-open-stream-permission-denied How to fix Error: laravel.log could not be opened?

Then

semanage fcontext -a -t httpd_sys_rw_content_t "/var/log/sync.log"
restorecon -rv /var/log/

1 Answers1

0

can you specify the exact error you are getting, because I tried your code and its working fine.

Otherwise you can try with a system command as given below -

<?php
    system('grep "Finished" /var/log/sync.log | tail -n1;');
?>
P N Jain
  • 302
  • 1
  • 13