Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kdb+ - how to start process without blocking the terminal in linux

Tags:

bash

kdb+

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
like image 472
Piotr Borowczynski Avatar asked Oct 19 '25 06:10

Piotr Borowczynski


1 Answers

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.

like image 104
brunorey Avatar answered Oct 21 '25 02:10

brunorey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!