Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Automatically Running Perl Script

by perl.j (Pilgrim)
on Sep 10, 2011 at 23:53 UTC ( [id://925299]=perlquestion: print w/replies, xml ) Need Help??

perl.j has asked for the wisdom of the Perl Monks concerning the following question:

Is it possible to have a Perl Script constantly running while my PC is on?

Update: Is it possible?

--perl.j

Replies are listed 'Best First'.
Re: Automatically Running Perl Script
by NetWallah (Canon) on Sep 11, 2011 at 05:43 UTC
    Seeing that you are a High school kid who may never have heard these terms, I'll throw out a few words related to your quest for a continuously running program that starts automatically.

    Such a program is called a daemon in the Linux world, or a service in the Windows world.

    There are several perl modules on CPAN that can help create programs that run in this manner.

    If you pose a more specific question about what you are trying to do, what research you have done, and what problem you encounter when attempting to implement such a program, I'm sure monks here will be sympathetic and helpful.

                "XML is like violence: if it doesn't solve your problem, use more."

Re: Automatically Running Perl Script
by zentara (Archbishop) on Sep 11, 2011 at 11:34 UTC
    You need to decide whether you want an output terminal, output to a file, where to log to, etc. Usually programs that run constantly are put into a background process or daemonized. You can daemonize most scripts with Proc::Daemon

    See How to know if a perl script is put in the background too, for monitoring background processes.

    Another consideration, is where you start and stop the program. If you are on linux, there are scripts that run at startup and shutdown, and you can work your script into that mechanism, for automatic start/stop with powerup/powerdown events.

    You really should be more specific in what type of script you envision running.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Automatically Running Perl Script
by pvaldes (Chaplain) on Sep 11, 2011 at 14:34 UTC
    If you use Linux take a look to the examples here. Cron can take and run any perl script. If you need a time-lapse lesser than one minute you can use a daemon instead.
Re: Automatically Running Perl Script
by GrandFather (Saint) on Sep 11, 2011 at 00:05 UTC

    Yes. Was there another question?

    True laziness is hard work

      C'mon, GrandFather! Be helpful! perl.j obviously wants us to show him how. ;-)

      C:\>perl -e while(1){}
        So I just run that exactly as written? Or do I have to add something to it?
        --perl.j

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://925299]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-20 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found