Thread: Executing a bunch of Specific commands at specified intervals.

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    50

    Executing a bunch of Specific commands at specified intervals.

    Hello out there.

    I'm interested of building an app that will read from a .txt file such the below one, a list of commands (mainly bash scripts), run them at the specified intervals and get their output.

    Such a file will look like :

    Code:
    [update]
    command=./scripts/updates.sh
    interval=7
    
    [time]
    command=./scripts/time.sh
    interval=16
    Which is the best approach on such idea? Should I create a child process for every command and inside it create a timer with the specified interval or there are more efficient ways to do such a thing ?

    Any idea or suggestion is welcomed.

  2. #2

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    50
    Thank you for your answer but I don't want to use crontab because I'm planning to add some more functionalities like to get the results of the scripts and send them in a proper format to server application. I prefer to do this through C.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    But what you posted was essentially a crontab written in another format.

    Eg
    */7 * * * * ./scripts/updates.sh
    */16 * * * * ./scripts/time.sh


    > add some more functionalities like to get the results of the scripts and send them in a proper format to server application
    So
    */7 * * * * ./scripts/updates.sh && sendResultsToServer
    */16 * * * * ./scripts/time.sh && sendResultsToServer


    Since you're just a bash'er, you can always wrap updates.sh in updateAndSend.sh to combine the 'updates.sh' with whatever processing you need to send to your server.

    > Any idea or suggestion is welcomed.
    ...
    > I prefer to do this through C.
    You seem to be trying really hard to justify re-inventing the wheel.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. executing commands
    By cstudent in forum C Programming
    Replies: 2
    Last Post: 04-24-2008, 02:59 AM
  2. executing cmd.exe commands?
    By Dragoon_42 in forum C++ Programming
    Replies: 3
    Last Post: 11-03-2005, 12:22 PM
  3. Executing OS Commands via my C# Program
    By gozlan in forum C# Programming
    Replies: 2
    Last Post: 07-05-2003, 01:30 AM
  4. executing commands from new terminals
    By LinuxPLC in forum C Programming
    Replies: 1
    Last Post: 02-19-2003, 12:47 PM
  5. Executing shell/dos commands
    By Zaarin in forum C++ Programming
    Replies: 2
    Last Post: 08-28-2001, 10:29 PM

Tags for this Thread