Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

timers in unix

5 posters

Go down

timers in unix Empty timers in unix

Post by akalya Fri Mar 05, 2010 7:05 pm

ny idea as to how to implement timers in unix???

tat is i want to execute a particular command at regular intervals.....how cud i do this???

akalya

Posts : 70
Points : 86
Join date : 2010-03-04

Back to top Go down

timers in unix Empty Re: timers in unix

Post by Maithreyi Fri Mar 05, 2010 7:13 pm

You can put it in a while loop and use sleep(5).It will pause for 5 sec and den resume.

say while(1)
do
some code
sleep(5)
done

Maithreyi

Posts : 76
Points : 142
Join date : 2010-03-03
Age : 36
Location : Haldia

Back to top Go down

timers in unix Empty Re: timers in unix

Post by anand Fri Mar 05, 2010 7:18 pm

[335723@oracleclient ~]$ sleep 5 && cat hello.txt

it can be used for single line command.......
it ll delay 5 secs .....
anand
anand

Posts : 55
Points : 70
Join date : 2010-02-26
Age : 36

Back to top Go down

timers in unix Empty Re: timers in unix

Post by akalya Fri Mar 05, 2010 7:25 pm

Thanks Wink
but how to do u repeat the execution of a particular command
say every 5sec i want to display hello world msg

akalya

Posts : 70
Points : 86
Join date : 2010-03-04

Back to top Go down

timers in unix Empty Re: timers in unix

Post by Christopher Mon Mar 08, 2010 1:34 pm

try this pgm

Code:
while(true)
do
echo Hello World
sleep 3
done
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

timers in unix Empty Re: timers in unix

Post by jeeva Mon Mar 08, 2010 1:36 pm

for ((i=0 ;; i++))
do
echo hello
sleep 1
done


how about this!!

jeeva

Posts : 50
Points : 93
Join date : 2010-03-04

Back to top Go down

timers in unix Empty Re: timers in unix

Post by akalya Mon Mar 08, 2010 1:49 pm

hey thanks Smile

akalya

Posts : 70
Points : 86
Join date : 2010-03-04

Back to top Go down

timers in unix Empty Re: timers in unix

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum