Program that wakes up every hour
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Program that wakes up every hour




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Program that wakes up every hour  
Digital Puer


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-22-07 06:24 AM

I have a C++ program running on Red Hat Linux
that needs to wake up every hour, read a database
through ODBC, and perform accumulations and
other calculations (e.g. to count inventory sold
in the last hour). The problem is such that there
are so many transactions around the world that
real-time aggregation is not feasible, so it must
be done hourly.

I have several design choices:

1. The program can always be running. It can call
sleep() to sleep the remaining minutes until the next
hour.

2. The program can block on, say, a named pipe,
and another hourly program can write to the named
pipe to wake it up. This hourly program can be
started by cron.

3. The program can itself be stateless and kicked
off by cron. When it's started, it reads the database,
runs calculations, and writes back immediately
to the database.

Any opinions?






[ Post a follow-up to this message ]



    Re: Program that wakes up every hour  
Ian Collins


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-22-07 06:24 AM

Digital Puer wrote:
> I have a C++ program running on Red Hat Linux
> that needs to wake up every hour, read a database
> through ODBC, and perform accumulations and
> other calculations (e.g. to count inventory sold
> in the last hour). The problem is such that there
> are so many transactions around the world that
> real-time aggregation is not feasible, so it must
> be done hourly.
>
> I have several design choices:
>
> 1. The program can always be running. It can call
> sleep() to sleep the remaining minutes until the next
> hour.
>
> 2. The program can block on, say, a named pipe,
> and another hourly program can write to the named
> pipe to wake it up. This hourly program can be
> started by cron.
>
> 3. The program can itself be stateless and kicked
> off by cron. When it's started, it reads the database,
> runs calculations, and writes back immediately
> to the database.
>
> Any opinions?
>
3 - that's what cron is for!

--
Ian Collins.





[ Post a follow-up to this message ]



    Re: Program that wakes up every hour  
waiting for


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-22-07 12:30 PM

On 3=D4=C222=C8=D5, =CF=C2=CE=E712=CA=B115=B7=D6, "Digital Puer" <digital_p=
.=2E.@hotmail.com> wrote:
> I have a C++ program running on Red Hat Linux
> that needs to wake up every hour, read a database
> through ODBC, and perform accumulations and
> other calculations (e.g. to count inventory sold
> in the last hour). The problem is such that there
> are so many transactions around the world that
> real-time aggregation is not feasible, so it must
> be done hourly.
>
> I have several design choices:
>
> 1. The program can always be running. It can call
> sleep() to sleep the remaining minutes until the next
> hour.
>
> 2. The program can block on, say, a named pipe,
> and another hourly program can write to the named
> pipe to wake it up. This hourly program can be
> started by cron.
>
> 3. The program can itself be stateless and kicked
> off by cron. When it's started, it reads the database,
> runs calculations, and writes back immediately
> to the database.
>
> Any opinions?

I think using a timer is a good idea! Isn't it?






[ Post a follow-up to this message ]



    Re: Program that wakes up every hour  
Lew Pitcher


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-22-07 12:30 PM

On Mar 22, 12:15 am, "Digital Puer" <digital_p...@hotmail.com> wrote:
> I have a C++ program running on Red Hat Linux
> that needs to wake up every hour, read a database
> through ODBC, and perform accumulations and
> other calculations (e.g. to count inventory sold
> in the last hour). The problem is such that there
> are so many transactions around the world that
> real-time aggregation is not feasible, so it must
> be done hourly.
>
> I have several design choices:
>
> 1. The program can always be running. It can call
> sleep() to sleep the remaining minutes until the next
> hour.

Of course, when your CIO or CFO comes back and tells you that he needs
inventory levels collected at half-hour intervals /for next month
only/, you'll have to implement a couple of program changes.

> 2. The program can block on, say, a named pipe,
> and another hourly program can write to the named
> pipe to wake it up. This hourly program can be
> started by cron.

Hmmmm... one program blocks on a resource that is only released by a
program run by cron.
*Why not just use cron to run the first program??*

> 3. The program can itself be stateless and kicked
> off by cron. When it's started, it reads the database,
> runs calculations, and writes back immediately
> to the database.

Good choice - no program changes, no convoluted operational setup, and
uses a simple tool which is /meant/ for the task.

> Any opinions?

C: cron - final answer.

--
Lew






[ Post a follow-up to this message ]



    Re: Program that wakes up every hour  
David T. Ashley


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-22-07 06:27 PM

"Digital Puer" <digital_puer@hotmail.com> wrote in message
news:1174536916.769154.249640@y80g2000hsf.googlegroups.com...
>I have a C++ program running on Red Hat Linux
> that needs to wake up every hour, read a database
> through ODBC, and perform accumulations and
> other calculations (e.g. to count inventory sold
> in the last hour). The problem is such that there
> are so many transactions around the world that
> real-time aggregation is not feasible, so it must
> be done hourly.
>
> I have several design choices:

<SNIP>

This is one of those occasional problems where there is no clear best
choice.

#2 is interesting, because I guess you could in principle have the program
running all the time, but use a short program executed via cron to write to
the named pipe (i.e. a combination of #1 and #3).

I believe #3 is the simplest and the most direct.  "cron" is intended for
that purpose.  But the other solutions don't seem bad, either.

--
David T. Ashley              (dta@e3ft.com)
http://www.e3ft.com          (Consulting Home Page)
http://www.dtashley.com      (Personal Home Page)
http://gpl.e3ft.com          (GPL Publications and Projects)







[ Post a follow-up to this message ]



    Re: Program that wakes up every hour  
Daniel Rudy


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-24-07 12:27 PM

At about the time of 3/21/2007 9:15 PM, Digital Puer stated the following:
> I have a C++ program running on Red Hat Linux
> that needs to wake up every hour, read a database
> through ODBC, and perform accumulations and
> other calculations (e.g. to count inventory sold
> in the last hour). The problem is such that there
> are so many transactions around the world that
> real-time aggregation is not feasible, so it must
> be done hourly.
>
> I have several design choices:
>
> 1. The program can always be running. It can call
> sleep() to sleep the remaining minutes until the next
> hour.
>
> 2. The program can block on, say, a named pipe,
> and another hourly program can write to the named
> pipe to wake it up. This hourly program can be
> started by cron.
>
> 3. The program can itself be stateless and kicked
> off by cron. When it's started, it reads the database,
> runs calculations, and writes back immediately
> to the database.
>
> Any opinions?
>

Use cron.


--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:18 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register