简体   繁体   中英

How can I display if a process is running on my web page?

I want to be able to display on my web page whether or not a process is running. Both run on the same system (Ubuntu server).

Basically, if something like the command ps -u game | grep java returns something, I want the site to display something like "Game Server Online", else "Offline."

I figure I could redirect the grep output to a file every 5 mins and have a script on the main page read the file content as a string to determine what to print. I feel as though there is be a much better way to do this, however. What else could I do and which scripting language would be best for this task?

If php is available, you could do something like this inline in your page:

<?php
$output = shell_exec('ps -u game | grep java');
if ($output === "java something") {
    echo "Server running"
} else {
    echo "Server not running"
}
?>

what about a simple web service call? calling a web service would ensure that both the server is up and the process is running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM