Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Systems > Linux / BSD / OS X
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 02-25-2003, 08:21 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
checking if a process exists

On my game servers, I have a stats program written in perl running in the background. It listens for log information that is sent from Half-Life.

Since the perl script runs in the background, it is difficult to determine if it is running unless I ssh in and execute:
Code:
ps aux |grep hlstats.pl
so now i want to make a script that i can view from a web page that verifies that the process is running.

here is how i start the script:
Code:
-nohup ./hlstats.pl &
i'd prefer to be able to do this all in php, however i haven't been able to get info back from an exec() command in php.

can anyone suggest what they think is the best way to accomplish this?
__________________
sde is offline   Reply With Quote
Old 02-25-2003, 09:52 AM   #2 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
try the popen() function instead of exec().
__________________
joe_bruin is offline   Reply With Quote
Old 02-26-2003, 02:30 PM   #3 (permalink)
sdeming
Code Monkey
 
Join Date: Jul 2002
Location: Michigan
Posts: 85
sdeming is on a distinguished road
1. Have hlstats.pl write it's PID to /var/run/hlstats.pl.pid
2. Have your PHP script read PID from the /var/run/hlstats.pl.pid file
3. Look in /proc/PID to see if the process is still active.

Works good this way.
__________________
Scott
B4 09 BA 09 01 CD 21 CD 20 53 63 6F 74 74 24
sdeming is offline   Reply With Quote
Old 02-26-2003, 02:56 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
great thinking! =) thanks..

now i'm not sure how to have the hlstats.pl script write its own pid.
__________________
sde is offline   Reply With Quote
Old 02-26-2003, 06:07 PM   #5 (permalink)
sdeming
Code Monkey
 
Join Date: Jul 2002
Location: Michigan
Posts: 85
sdeming is on a distinguished road
In perl, use the predefined variable $$, for example:
Code:
print "PID: $$\n";
__________________
Scott
B4 09 BA 09 01 CD 21 CD 20 53 63 6F 74 74 24
sdeming is offline   Reply With Quote
Old 02-28-2003, 04:22 AM   #6 (permalink)
schotty
RedHat's Manwhore
 
schotty's Avatar
 
Join Date: Feb 2003
Location: Milwaukee
Posts: 41
schotty is on a distinguished road
Send a message via ICQ to schotty Send a message via AIM to schotty Send a message via Yahoo to schotty
Would this link be of interest?

Half life daemon
__________________
schotty is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
checking system configuration with JAVA callmefiero Java 3 08-26-2004 02:38 AM
Checking disk quota on multi-user system Antagony Linux / BSD / OS X 3 04-13-2003 11:59 AM
Using Includes to streamline the design process sde PHP 0 02-16-2003 11:49 PM
killing a process by name? sde Linux / BSD / OS X 9 12-20-2002 01:39 PM
checking datatypes in c++ brtklt All Other Coding Languages 5 07-10-2002 03:57 AM


All times are GMT -8. The time now is 09:14 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle