How to run the particular command continously for 30 mins in perl?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run the particular command continously for 30 mins in perl?
# 1  
Old 07-27-2010
How to run the particular command continously for 30 mins in perl?

Hi,

I have command that should run continuously for 30 mins but not every day not once in a week , not one in a month. whenever i call that particular program that command should run for 30 mins and stop.

Code:
  
#Contents of test.pl

`ls -l *.txt`;

#some other lines of code to print

When ever i call test.pl the ls -l command (For example) should run continuously for 30 mins and stop.

How can i do this in perl?

Can crontab be used if so we need to give day month and year etc but i might run this program daily or i may not run for 0ne year etc, One month or even not even daily i run.

Any suggestions?


Regards
# 2  
Old 07-27-2010
Wanna DOS your server???

Code:
my $secs = print time();
my $targetsecs = $secs + (30 * 60);

while ($secs < $targetsecs) {
system("ls -l *.txt");
$secs = print time();
}

However, I would use at least a 1sec sleep.

Code:
my $secs = print time();
my $targetsecs = $secs + (30 * 60);

while ($secs < $targetsecs) {
system("ls -l *.txt");
sleep 1s;
$secs = print time();
}


Last edited by STOIE; 07-27-2010 at 01:54 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run the script continously but mail once in 1 hour

Hi, I have a script written for monitoring the queue manager status continously. below is the script. QMGR=`dspmq | awk '{print $1}' | cut -f2 -d "(" | cut -f1 -d ")"` QMSTATUS=`dspmq | awk '{print $2}' | cut -f2 -d "(" | cut -f1 -d ")"` count=`dspmq | awk '{print $1}' | cut -f2 -d "(" | ... (5 Replies)
Discussion started by: Anusha M
5 Replies

2. Shell Programming and Scripting

Run Bash Script thrice & then interval for 10 mins.

Hi... I am very new to shell scripting. I have written a script with help of this forum and some googling and it works the way I want it to. Currently this script checks for my SIP trunk registration every 5 seconds, if registration is not available then it reboots my router through telnet... (4 Replies)
Discussion started by: jeetz
4 Replies

3. Shell Programming and Scripting

Perl: How to run an POST/GET command via proxy?

Please what is the most simple way to run some perl command via proxy? i have perl script an in it: POST **something** GET **something** what should i do before it so its proxified via proxy without authentiffication, like 1.2.3.4:1080? any way to run whole .pl script via proxy? (3 Replies)
Discussion started by: postcd
3 Replies

4. Shell Programming and Scripting

Better way to run this perl command

i'm working with files that are huge in size. over 3GB. and i need to do a lot of pattern matching. I need a way to grep for what i want, using a tool that is available across most unix systems. i initially was gungho about grep, but not all capablities of grep are available on all OSes. so... (10 Replies)
Discussion started by: SkySmart
10 Replies

5. Shell Programming and Scripting

How to schedule a cronjob to run every 15 mins ?

Hi, I want to schedule a job to run every 15 mins through cron. searched the forums and came up with this piece of code.i have given this in my crontab 0-59/15 * * * * sh /usr/ss/job But its not being run. Have i made any mistake here. Can any1 post the cron code for scheduling the... (5 Replies)
Discussion started by: suresh_kb211
5 Replies

6. Shell Programming and Scripting

Perl - To print past 5 mins timestamp

hi , I would like to ask how to get past 5 minutes system time and date, if i have following to get current time. # get current time ($sec,$min,$hour,$mday,$mon,$year) = localtime(time); $year = $year + 1900; $mon = sprintf ("%02s",$mon+1); $mday = sprintf ("%02s",$mday); $hour =... (1 Reply)
Discussion started by: rauphelhunter
1 Replies

7. UNIX for Dummies Questions & Answers

Script should run continously

Hi I have a small req. I have a script called as abc.sh I want to execute this script continously for every 1 minute even if i exit from the server i.e., it should keeps on running for every one minute even if i logged off Can any one send me the sample code or procedure to work... (3 Replies)
Discussion started by: pssandeep
3 Replies

8. Shell Programming and Scripting

run a command automatically after every 10 mins

Hi friends, I need to write a script which runs a command (on that particular server only) after every 10 mins, and the contents are also echoed on that very terminal only. And then I need to compare the last two outputs, and mail if there is any difference in the last two outputs. Can we set... (4 Replies)
Discussion started by: vikas027
4 Replies

9. UNIX for Dummies Questions & Answers

command to run a command after 30 mins

how to schedule a command to run after 30 mins ? (3 Replies)
Discussion started by: gridview
3 Replies

10. Shell Programming and Scripting

Perl run system command

Can perl execute a system command similar to the C function System()? Thanks. Gregg (1 Reply)
Discussion started by: gdboling
1 Replies
Login or Register to Ask a Question