cancel
Showing results for 
Search instead for 
Did you mean: 

How do I make logging continue?

Mannix
New Contributor III
New Contributor III

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

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

 







2 ACCEPTED SOLUTIONS

samuelholst
New Contributor

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

View solution in original post

eohara
New Contributor III
New Contributor III

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).

View solution in original post

3 REPLIES 3

pmallon
New Contributor III
New Contributor III

Hi Mannix,

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

 

 

Thanks,

Patrick

samuelholst
New Contributor

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
New Contributor III
New Contributor III

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).