Program that wakes up every hour - Unix

This is a discussion on Program that wakes up every hour - Unix ; 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 ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Program that wakes up every hour

  1. Program that wakes up every hour

    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?


  2. Re: Program that wakes up every hour

    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.

  3. Re: Program that wakes up every hour

    On 3月22日, 下午12时15分, "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?


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


  4. Re: Program that wakes up every hour

    On Mar 22, 12:15 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.


    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


  5. Re: Program that wakes up every hour

    "Digital Puer" wrote in message
    news:1174536916.769154.249640@y80g2000hsf.googlegr oups.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:




    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)



  6. Re: Program that wakes up every hour

    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

+ Reply to Thread