How Can I check if a script is still running ?

  • barry
  • Graduate
  • Graduate
  • User avatar
  • Posts: 115
  • Loc: scotland

Post 3+ Months Ago

Hi all. I run a trackmania server and I use putty to start a php script which i nohup so i can close the consol. Thing is the php script sometimes stops and i have no warning as to when the script bums out so what im looking for is a way to monitor whether the script is still running or not. I would like to be either emailed to tell me the script has failed so that i can go start it up again using putty or is it possible to just use a cron job to check to see if the script is running and if it is not running start it up automatically?

Any help or advice would be great!!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • dark_lord
  • Graduate
  • Graduate
  • User avatar
  • Posts: 162
  • Loc: India-Kolkata

Post 3+ Months Ago

i think you can't allow a php script to run all your life, maximum execution is 30seconds by default, though you can change that which is not recommended.

Anyways you can use http://in2.php.net/manual/en/function.mail.php mail function to know how to send yourself email when certain thing stops working.
  • barry
  • Graduate
  • Graduate
  • User avatar
  • Posts: 115
  • Loc: scotland

Post 3+ Months Ago

mmm... I dont know about that? I am running a php script on my game server for trackmania and sometimes it is running for a whole day. Like i said above i nohup it through the consol... php is then in the list of running processes when i ps -e the consol. I see it there and it has a process number which i can kill if needed but I want alerted when it dies.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

First thing that comes to mind for me is to start the script as a special user, named "scriptuser" or something.

Then you can periodically check the list of processes using top/etc for that username. If the process list doesn't include anything running as "scriptuser", it's probably safe to say the script isn't running.
  • barry
  • Graduate
  • Graduate
  • User avatar
  • Posts: 115
  • Loc: scotland

Post 3+ Months Ago

hi and thanks for the reply. I dont want to periodically check the script. What i am looking for is a php script that will check to see if ythe process is still running and that is activated using cron and if the script is not running then i will get an email or it will restart the script for me.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 111 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.