Raggaer
Raggaer

Reputation: 3318

Read linux console PHP

I want to read the console logs of a process that is running, I currently have this

$output = shell_exec('pgrep tfs');
echo "<pre>$output</pre>";

And that returns me a random number like 34034

I've almost never worked with linux before so I dont really know how to do this.

Upvotes: 0

Views: 58

Answers (1)

Machavity
Machavity

Reputation: 31614

You do realize that that's what pgrep does, right? It returns the process ID of the process you're asking about. So that's not a random number you're getting back. Your script is working perfectly.

Why don't you find the actual log file itself (usually in /var/logs) and use something like fopen to open and parse it?

Upvotes: 2

Related Questions