2022.04.03 04:05 AM - edited 2022.04.15 06:26 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]," Out\n")];.log.err[(string[.z.P]," Error\n")]}
\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
////////////////////////////////
2022.04.04 02:15 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
2022.04.04 02:37 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).
2022.04.03 04:21 AM
Hi Mannix,
Try >> new.log to append to the file.
Thanks,
Patrick
2022.04.04 02:15 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
2022.04.04 02:37 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).
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.