4

I am trying to run couple of processes on linux of kdb+(TP, RDB, HDB)

e.g

q tick.q sym /mnt/disks/disk1/OnDiskDB/ -p 5000

The problem which I have is that I have to keep terminals opened to keep q processes running

Below are my steps:

I tried:

q tick.q sym /mnt/disks/disk1/OnDiskDB/ -p 5000 &

but then I have to manually hit enter to exit q prompt (which could be still ok), some info about processes stops and then I am closing terminal

[piotr@server tick-example]$ q tick.q sym /mnt/disks/disk1/OnDiskDB/ -p 5000 &
[1] 6627
[piotr@server tick-example]$ KDB+ 3.6 .....
q)    (enter)
[piotr@server tick-example]$   (hitting enter)
[piotr@server tick-example]$  (hitting enter)
[1]+  Stopped                 q tick.q sym mnt/disks/disk1/OnDiskDB/ -p 5000
[piotr@server tick-example]$ 

But it seems that process is still running

[piotr@server tick-example]$ ps -efww | grep tick
piotr    6627  6408  0 14:55 pts/7    00:00:00 q tick.q sym /mnt/disks/disk1/OnDiskDB/ -p 5000

And now closing terminal

Opening another terminal for verification:

[piotr@server tick-example]$q
...
q)h:hopen `::5000
'hop. OS reports: Connection refused
  [0]  h:hopen `::5000
q)\\
[piotr@server tick-example]$ ps -efww | grep tick
...
nothing
  • Side note, this has nothing to do with kdb. You might run into the same issue with any command. It is more about the unix shell. – brunorey Mar 06 '19 at 17:31

3 Answers3

6

You should read a bit more about how background and foreground processes run in a shell. Basically you are not detaching by adding a & at the end of your command, it still depends on your shell and your input.

Here is a down-to-the-point explanation on what you should use for different cases.

  • Running command & simply sends the command to bg so you can keep using your terminal
  • Running nohup command & > /dev/null is the safest combination if you want to keep you process running independently from your shell (replace /dev/null with whatever file you want).

Also read about the Job control commands. TLDP has a good article.

brunorey
  • 2,135
  • 1
  • 18
  • 26
0

Try to add

nohup

before your commands

Fseee
  • 2,476
  • 9
  • 40
  • 63
0

This issue is more of a unix/shell related than KDB as already mentioned by others. Below is one solution that you can try.

When you send a process to background and if that process is still waiting for an input from terminal then it goes into a stopped state. In that case it will not accept request from other KDB process. And that is what you are seeing.

To fix this, you need to change stdin to detach terminal input. Below command redirects output to some log file and also change stdin to /dev/null.

'nohup' command is used so that process will keep running even after terminal is closed.

nohup q -p 5000 >output.log </dev/null &

Now you can eaily connect from other kdb service:

 q)h:hopen `::5000
 q)h ".z.K"
 q)3.5
Rahul
  • 3,914
  • 1
  • 14
  • 25