English 中文(简体)
我怎么能适当观察 p子的指挥?
原标题:How can I properly watch psql command?

Seed

我推出我的数据库

curl -s http://site/api/seed/user/1000

Test

我这样做了。

psql --username=nm -d portal -h 192.168.1.27 -c "SELECT count(*) from users;"

 count                                                                                                                                                                                 
-------                                                                                                                                                                                
  1000                                                                                                                                                                                 
(1 row)

Watch

watch psql --username=nm -d portal -h 192.168.1.27 -c "SELECT count(*) from users;"

Every 2.0s: psql --username=nm -d portal -h 192.168.1.27 -...  bh-macbook-pro-15-512gb.local: Tue Nov 21 15:19:08 2017

sh: -c: line 0: syntax error near unexpected token `(                                                                          
sh: -c: line 0: `psql --username=nm -d portal -h 192.168.1.27 -c SELECT count(*) from users;  

我如何纠正这一错误?

问题回答

1. 提供指挥作为单一援引的论点:

watch  psql --username=nm -d portal -h 192.168.1.27 -c "SELECT count(*) from users;" 

Use the commande watch of psql

One line in terminal

To run everything in one command in your terminal, echo your SQL QUERY with the addition watch at the end and use the pipe | to provide your psql command. If you use the psql command with the argument -c the watch command will not work (the -c necessarily ends with a semicolon ; and therefore the command watch; is not recognized).

echo  YOUR_SQL_QUERY; watch  | psql [your_connection]

例:

echo  SELECT count(*) from users; watch  | psql --username=nm -d portal -h 192.168.1.27

Interactive terminal

To execute the command directly on PostgreSQL interactive terminal of psql, once connected to your database, execute your command and then use the watch command. 例:

SELECT count(*) from users;
watch

Description of the commande watch:

watch [ i[nterval]=seconds ] [ c[ount]=times ] [ seconds ]

一再执行目前的盘点缓冲(如 g)直至被打断,或达到执行限额(如果有)。 否认处决之间特定数目的二分数(过失2)。 对于后向相容性,二者可以与预设装置一起或没有间隔。 每个查询结果都有一张头盔,其中包括打字标题(如果有的话)、起立时间以及间隔时间。

来源:





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签