process

Ryan Paul segphault at sbcglobal.net
Wed May 12 06:49:41 EDT 2004


On Wed, 12 May 2004 12:33:16 +0200, José wrote:

> I have a farm with 4 web servers.
> I want to write a client-server program to rotate logs.
> Basically the server has only one file, if I run it, the server listens.
> The client has 2 files, one client and another server.
> If the log is greater than xxx bytes, then the client send a message to 
> the server, then the server send another message to all the webservers, 
> and they must to rotate logs.
> I'm too new in Python and I don't know a lot of modules, so the problem 
> is: how can I know which processes are running?.
> I writed all, but I want that the "client server" look at the processes.
> In case it's rotating logs, it must pause all. In bash it could be:
> 
> #ps ax|grep rotatelogs
> 
> But how in Python?
> 
> thanks in advance

I'm not aware of any way to retrieve the process list from python, but you
might try this:

import commands

x = commands.getstatusoutput('ps ax|grep rotatelogs')[1]



More information about the Python-list mailing list