Gossamer Forum
Home : General : Perl Programming :

Process Running...

Quote Reply
Process Running...
Hi. I'm trying to write a script that will automate the process of doing DMOZ dumps. Basically, the process would be;

1) Run itself every 30 mins (to see what is going on with the server, i.e if nph-import is running)
2) Check to see if the service is running (nph-import.cgi)
3) If it has stopped, the process is assumed to have been completed. Then it will execute SQL queries to dump all the required tables into a SQL dump on my server.
4) Once the dump has been done all of the info will be removed, and a new cron file will be written to work on the new category.
5) The above will continue until the end of all the categories (i'm estimating it will take a week, possibly 1 and a half to complete the whole directory). Then the process will not be run again until 2 weeks after, which will then re-import the new content RDF file and start the process again on the new dumps.

However, the problem I am finding is that I'm not sure how to work out if a process is running. I know it must be possible to do with a command line, as WebMin uses something to show all the running processes on one of its admin page.

Does anyone have any ideas on this one?

Thanks

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Process Running... In reply to
Try a system command something like:

ps --user andy

Then just use grep or something to match what you want.


Quote Reply
Re: [RedRum] Process Running... In reply to
Mmm, thanks for the help, but it doesnt seem to have the desired results. Typing ps --user nobody I get;

6412 ? 00:00:12 httpd
6413 ? 00:00:32 httpd
6414 ? 00:00:09 httpd
6415 ? 00:00:31 httpd
6469 ? 00:00:10 httpd
6476 ? 00:00:10 httpd
6477 ? 00:00:10 httpd
6508 ? 00:00:11 httpd
6758 ? 00:00:31 httpd
8118 ? 00:00:10 httpd

Any more ideas?

Thanks

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Process Running... In reply to
And you have an import running as we speak?

Definitely running under nobody?

Quote Reply
Re: [RedRum] Process Running... In reply to
Yup, here is a bit of what I see I WebMins 'Running Processes' option;

Process ID CPU Command
19724 99.7% perl /home/ace-host.com/public_html/dump/cgi/admin/nph-impor ...

Crazy

Thanks


Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Process Running... In reply to
Well that should be running under your username not nobody.
Quote Reply
Re: [RedRum] Process Running... In reply to
Well, just tried it as ps with my username, and still only get;

21101 pts/2 00:00:00 sh
21123 pts/2 00:00:00 ps

Is there a way to reference those numbers with a process?Like the actual command line being executed? Unsure

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [RedRum] Process Running... In reply to
Ah, the command I needed to use was ps -ax. Thanks for the pointer to ps,as that is what helped me find what I wanted Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!