Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Re: Re: Infinte perl script

by mr_leisure (Beadle)
on Jan 05, 2001 at 13:43 UTC ( #50024=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Infinte perl script
in thread Infinte perl script

Howdy -

This is my first attempt at an answer to a question so go easy on me if i screw it up folks :P

I have a chunk of code that runs a df command on a specified directory, and will loop every x seconds as you choose. You can find it here for your reference ( the part you need is in the second script ,

For quickness, the code i use to loop it is -

until (! $opt{time}) { # loop every specified seconds { check_disk_space($opt{dir} ) ; # run my df subroutine on specified d +irectory sleep ($opt{time}) # wait specified time, then begin again }
What this basically does is uses the GetOpt::Long module to accept and process command-line parameters entered by the user, and then uses the untilstatement to run the loop according to the parameters entered.

So what you could do in theory is put a line in your cron to start it ( -dir =/usr/bin/perl -time=120) which would then run the script every two minutes on the /usr/bin/perl directory.

As I said, this is my first *serious* answer, so if I have rambled, I apologise, but I sincerely hope this helps, if only on the sleep thing. I hope you like Getopt though, cause it's been totally handy for me.

Cheers, jim
if ($mr_leisure) { bow; }
this is still not finished

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://50024]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-09-27 08:40 GMT
Find Nodes?
    Voting Booth?

    No recent polls found