how to check if ruby script is running in background from PHP script?

限于喜欢 提交于 2019-12-11 16:47:50

问题


say a ruby script is running

ruby.rb SOMEUSERID

using PHP, how can i find out whether something exactly like that is currently running or not ? Currently i am using PID to check but im not sure if this is efficient. What if there are lot of users running the ruby script, and the ruby script unexpectedly closes. The php script now looks for this PID, and then it turns out it's somebody else's ruby script....trouble ensues.


回答1:


I don't like the idea but you can do this on linux

exec('ps -A | grep ruby.rb', $output);

not sure what's about other systems.




回答2:


Parse output from 'ps ax' perhaps



来源:https://stackoverflow.com/questions/1626900/how-to-check-if-ruby-script-is-running-in-background-from-php-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!