[Tutor] how to run a process forever

shawn bright nephish at gmail.com
Wed Dec 10 20:15:18 CET 2008


Sorry, was not very specific in my request.

say i have a script like

while 1:
    do_something_cool()
    time.sleep(2)

i am running this on a linux computer. How would i check that it is
running? (from cron part)
and how do i kick it off when i boot the computer? ( the init script part)

thanks for your responses.
shawn

On Wed, Dec 10, 2008 at 12:34 PM, W W <srilyk at gmail.com> wrote:
> while True:
> is also a common way to make your program "run forever". Although you still
> need to create some sleep/wait function or it will eat up your available
> processes (so I'm told).
> -HTH,
> Wayne
> On Wed, Dec 10, 2008 at 12:28 PM, Steve Willoughby <steve at alchemy.com>
> wrote:
>>
>> On Wed, Dec 10, 2008 at 12:23:48PM -0600, shawn bright wrote:
>> > Hey gents,
>> >
>> > I have an interesting problem. I need to have a python script start
>> > when a computer boots up, and i need it to run forever.
>> > I also am going to run a script by cron that will check to see if the
>> > process is running, if not, i need a python script to execute
>> > the script.
>>
>> Maybe I'm misunderstanding your meaning, but usually programs which do
>> this don't do anything unusual other than... well... simply run forever
>> in the background (launched from the startup scripts or cron,
>> disassociated
>> from any TTY, of course).  A watchdog re-launcher cron script is also
>> not uncommon.
>>
>> If your script isn't actively doing something it's good to put it to
>> sleep until some interesting event (or timer) wakes it up.
>>
>> Was there something beyond that you were looking for?
>>
>> --
>> Steve Willoughby    |  Using billion-dollar satellites
>> steve at alchemy.com   |  to hunt for Tupperware.
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>
>
>
> --
> To be considered stupid and to be told so is more painful than being called
> gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
> every vice, has found its defenders, its rhetoric, its ennoblement and
> exaltation, but stupidity hasn't. - Primo Levi
>


More information about the Tutor mailing list