How to run a perl script after an interval of 10 seconds

V

vikrant

hi,

How can i run a perl script after an interval of 10 seconds on my
machine.

i have tried with Crotab but minimum time it requires is one minute.
please correct me if i am wrong.


Thanks

Vikrant
 
A

A. Sinan Unur

How can i run a perl script after an interval of 10 seconds on my
machine.

perldoc -f sleep
i have tried with Crotab but minimum time it requires is one minute.
please correct me if i am wrong.

Your question does not have anything to do with Perl. Read the docs for
your OS, or the utility you want to use. Ask in a gorup related to the OS
you are using to find out what alternatives are available.

Sinan
 
X

xhoster

vikrant said:
hi,

How can i run a perl script after an interval of 10 seconds on my
machine.

Type the command, wait 10 seconds, and hit enter.

Did you have a perl question?

Xho
 
V

vikrant

hi,

Sorry for not explaning the problem in detail.

Actually,my problem was not like that.

Trying to expalin the problem in a better way.

Suppose,my script /home/vikrant/hello.pl is as follows:-
-------------------------------
#!/usr/bin/perl -w
open(FILE,"+>>hello.txt");
print FILE"hello";
close(FILE);
----------------------------

So,what i am trying to do is to start the script automatically when my
system boot.
Also ,the same script execute again and again after a gap of 10
seconds.

To start it automatically after the system boot, i made the following
entry in /etc/rc.d/rc.local
----------------------------------
perl /home/vikrant/hello.pl &
-------------------------------------

Now,following entry in Crontab execute it again and again after a gap
of 1 minute.
-------------------------------------------
*/1 * * * * perl /home/vikrant/hello.pl
-----------------------------------------------

But,the Problem is in executing it again and again after a gap of 10
seconds.

Due to some reasons i need to void make use of while loop means
while(1).

So,please help me.

Thanks
Vikrant
 
J

Jürgen Exner

vikrant said:
Sorry for not explaning the problem in detail.
Actually,my problem was not like that.


Which problem? Was not like what?
Please quote an appropriate amount of context -as has been customary for 20
years- such that people have a chance to know what you are talking about.
Trying to expalin the problem in a better way.

Suppose,my script /home/vikrant/hello.pl is as follows:-
-------------------------------
#!/usr/bin/perl -w
open(FILE,"+>>hello.txt");
print FILE"hello";
close(FILE);
----------------------------

So,what i am trying to do is to start the script automatically when my
system boot.
Also ,the same script execute again and again after a gap of 10
seconds.

To the end of your script just add
sleep 10;
exec /home/vikrant/hello.pl;

You also may want to set up some kind of watchdog that restarts the script
independently in case it is terminated somehow.

jue
 
V

vikrant

hi,
Which problem? Was not like what?
Please quote an appropriate amount of context -as has been customary for 20 years- >such that people have a chance to know what you are talking about.

i shall not repeat this mistake in future.
To the end of your script just add
sleep 10;
exec /home/vikrant/hello.pl;
You also may want to set up some kind of watchdog that restarts the script
independently in case it is terminated somehow.

Thanks for the information.

Regards
Vikrant
 
J

Josef Moellers

Jürgen Exner said:
Which problem? Was not like what?
Please quote an appropriate amount of context -as has been customary for 20
years- such that people have a chance to know what you are talking about.




To the end of your script just add
sleep 10;
exec /home/vikrant/hello.pl;

Alternatively, the Perl-script could be modified to

while (1) {
open(FILE,"+>>hello.txt");
print FILE"hello";
close(FILE);
#
sleep 10;
}

Then it only needs to be started once and the complicated task of
compiling the hughe source would only have to be done once B-{)

Have a nice weekend,

Josef
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top