KX Community

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

Home Forums KX Academy How do I make logging continue?

  • How do I make logging continue?

    Posted by mannix on April 3, 2022 at 12:00 am

    I am currently learning how to use bash script and q together, to route stdout and stderr

    Here is my logging q file, called logger.q
    ///////////////
    .log.out: {-1 x};
    .log.err: {-2 x};
    .z.ts:{.log.out[(string[.z.P],” Outn”)];.log.err[(string[.z.P],” Errorn”)]}
    t 5000
    ///////////////

    When I start the q process and by running the command:

    nohup q logger.q > new.log 2>&1 &

    It only seems to have logged once, rather than every 5 seconds?

    Here is the log file, new.log:

    ////////////////////////////////

    nohup: ignoring input

    2022.04.03D11:03:10.586403000 Out

    2022.04.03D11:03:10.586550000 Error

    ////////////////////////////////

     

    mannix replied 8 months, 3 weeks ago 4 Members · 3 Replies
  • 3 Replies
  • pmallon

    Member
    April 3, 2022 at 12:00 am

    Hi Mannix,

    Try >> new.log to append to the file.

     

     

    Thanks,

    Patrick

  • samuelholst

    Member
    April 4, 2022 at 12:00 am

    Hi Mannix,

     

    You may need to specify a port using p in your logging q file – otherwise q will run

    through everything in the script and then exit without keeping the non-interactive process alive.

     

    Thanks,

    Samuel

  • eohara

    Member
    April 4, 2022 at 12:00 am

    the .z namespace | Reference | kdb+ and q documentation – Kdb+ and q documentation (kx.com) end of this section:

     

    When kdb+ has completed executing a script passed as a command-line argument, and if there are no open sockets nor a console, kdb+ will exit. The timer alone is not enough to stop the process exiting it must have an event source which is a file descriptor (socket, console, or some plugin registering a file descriptor and callback via the C API sd1 function).

Log in to reply.