You are here: Re: [PHP] How to determine if a script instance is already running? « PHP « IT news, forums, messages
Re: [PHP] How to determine if a script instance is already running?

Posted by Andrι Medeiros on 08/02/05 17:59

On Tue, 2005-08-02 at 09:49 -0400, Jim Moseby wrote:
> I have a command line script that needs to run continuously, and so I plan
> to have cron execute it every so often. I want to have the script first
> check to see if another instance is already running and, if so, die().
>
> Now, I know I can exec the process list and parse through the output, but is
> there and easier, faster, cooler, sexier, better way? :o)
>
> JM
>

Do like some services do:

1) Check if script.pid exists
2) If it doesn't
2.1) Write the process's PID onto the file
(http://pt.php.net/manual/en/function.getmypid.php)
3) If it does
3.1) Die gracefully :)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация