KX Community

Find answers, ask questions, and connect with our KX Community around the world.

Home Forums kdb+ cron job q script with timer

  • cron job q script with timer

    Posted by angela on June 10, 2021 at 12:00 am

    Hi,

    I can’t seem to get a q script with a timer to continue running in cron.
    For example:
    $ cat bin/test.q
    .z.ts:{0N!.z.Z;}
    t 2000
    If I run this normally it works fine. But when I try to put in in cron, it exits after one timer run. I tried using -t arg too but I can’t get the timer to repeat and continue running, it just exits after one run.
    I’m missing something or misunderstanding something…
    thanks
    angela replied 3 weeks, 4 days ago 3 Members · 2 Replies
  • 2 Replies
  • mklee

    Member
    June 19, 2021 at 12:00 am

    A q session would keep running if u didn’t call exit or //

    Assigning port or not doesn’t matter

  • kadir_kilicoglu

    Member
    August 13, 2021 at 12:00 am

    I copied this answer from your other question:

    Hello Angela,

    In your cronjob, you can start a script like;

    0 12 * * * sh /<path-to-your-script>/<your-script>.sh >> <path-to-your-output-log>/cronout.log 2>&1 &

     

     

    Then in this script file you can go with something like this;

     

    #!/usr/bin/env bash . <any-source-or-config-file-you-need-in-your-q-process>

    cd <to-your-q-script-folder> /home/<your-user>/q/l64/q <your-q-script>.q > <your-log-file-location>_$(date +’%Y.%m.%dT%H:%M:%S’).log 2>&1 &

     

     

    Notice the ampersand at the end; that ampersand will keep your process alive until you explicitly call exit in your q script.

    Hope this helps.

Log in to reply.