LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-10-2004, 01:12 AM   #1
wangjinyi
Member
 
Registered: Sep 2004
Posts: 60

Rep: Reputation: 15
How to use timer in redhat9


I want do somthing periodically.
I want use timer but how to do it.
would you give me some idea or examples.
anything will be helpful.
 
Old 10-10-2004, 02:12 AM   #2
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
You can use cron to start your program.

Code:
man 5 crontab
 
Old 10-10-2004, 02:32 AM   #3
wangjinyi
Member
 
Registered: Sep 2004
Posts: 60

Original Poster
Rep: Reputation: 15
that's good and the program will be start periodically.

but I want do it in the program, that means the program will be start only once.
 
Old 10-10-2004, 03:03 AM   #4
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
Code:
man 3 sleep
This might interst you as well.
Code:
man daemon
of course i'm assuming that you use C

Last edited by mirradric; 10-10-2004 at 03:05 AM.
 
Old 10-10-2004, 03:47 AM   #5
wangjinyi
Member
 
Registered: Sep 2004
Posts: 60

Original Poster
Rep: Reputation: 15
I want use somthing like timers.
I give it a period and a function to invoke, then when the
time specified by period comes to the end, the function
will be invoked automatically.

I like this way ,because it make the program logic clear.

do you know How to achieve this purpose.
 
Old 10-10-2004, 09:15 AM   #6
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
man alarm

...and...

man setitimer
 
Old 10-10-2004, 10:59 AM   #7
canavar_tayfun
LQ Newbie
 
Registered: Aug 2003
Location: turkey
Posts: 2

Rep: Reputation: 0
you can use threads.for example "i=1 to 1000" block takes 1 seconds to complete so that in a thread function,you can control the value (it is i) if equals to 1000,if equals to 1000 you can start a code block you want.
i actually didnt tried this example cos i just learned threads.but i think it will work ; ).(and also i will try by now : )
 
Old 10-10-2004, 11:41 AM   #8
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
Quote:
Originally posted by canavar_tayfun
you can use threads.for example "i=1 to 1000" block takes 1 seconds to complete so that in a thread function,you can control the value (it is i) if equals to 1000,if equals to 1000 you can start a code block you want.
i actually didnt tried this example cos i just learned threads.but i think it will work ; ).(and also i will try by now : )
Are you suggesting busy waiting (or whatever the term is)? This will eat up cpu even as it does nothing. Doing sleep and alarm are less expensive.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About timer.... help rajsun Programming 3 05-24-2005 06:06 AM
How to use timer in redhat9 wangjinyi Programming 3 10-08-2004 10:46 PM
RedHat9.0 1st-timer mbe Linux - Newbie 5 08-12-2004 11:09 PM
First timer, help!!!!! jcniest5 Linux - Newbie 7 02-24-2004 08:32 AM
A timer LOUDSilence Programming 1 12-08-2003 05:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration