开发者

How can I tell which Screen sessions are still running a PHP process from the command line?

I have about 25 Screen sessions running PHP scripts.

How can I tell which ones are still running the PHP process launched from that Screen session, without having to resume each Screen? Can I access this information from the command line with buil开发者_运维知识库t in functionality of screen or linux, or do I have to write scripts to handle this?

I started my screen sessions from the command line and executed the PHP scripts the same way.


If my memory serves me right, a screen session (if started with a command, I think it is -x) will kill itself (the screen will exit) when the program is finished running, so you could just parse the screen -list and see if the screen (with the session name you assigned it) is still there.

Alternatively (and what I would do) you could add a running row to a table when the script is started in the screen (with information like what it is doing, expected completion time, screen it's running on etc). Then just have the screen delete the row from the database when it completes, and you have a nice view of everything that is going on, and where it's happening.

You could even limit the number of screens, and have an administration program run in the background to assign jobs to screens (checking the database for when a screen is open).


Personally, I'd run a cronjob or script that will ps auxw | grep screen and then loop through each line, using awk and every other nice tool to see what is currently running on that tty and the idle time of that tty ... chances are, if the PHP script has finished running, it will show that there is nothing running on that tty and you can kill that screen or even just the tty ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜