.z.ts \t multiple timer calls - Kdb+ / qStudio

Home Forums Kdb+ / qStudio .z.ts \t multiple timer calls

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #140

    Oskar Morgenstern
    Guest

    We have a process on a timer that checks another database for new data every 10 minutes.
    We use
    \t 600000
    .z.ts:{ if[newData[]; log “fetching new data”; performSync[.z.t]];};

    We now want to add another timed process that will run once an hour to store data to disk.
    Is there a way to set multiple timers in kdb?

    #156

    You could override .z.ts, increment a counter and check for certain multiples to perform given actions. e.g.


    q)i:1
    q).z.ts:{ if[0=i mod 10; show `performSync]; if[0=i mod 60; show `storeDataToDisk]; i+:1; }
    q)\t 100
    q)`performSync
    `performSync
    `performSync
    `performSync
    `performSync
    `performSync
    `storeDataToDisk
    `performSync
    `performSync
    `performSync
    `performSync
    `performSync
    `performSync
    `storeDataToDisk
    `performSync
    `performSync

    Obviously this solution won’t scale. The next step could be to have a jobsTable that you add jobs to on certain recurring periods and set the next run time after execution. though again that will start to get messy. At which point fall back to crontab, autosys or something specifically designed for scheduling jobs.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.