【问题标题】:How can I properly watch psql command?如何正确观看 psql 命令?
【发布时间】:2018-05-05 10:38:20
【问题描述】:

种子

我为我的数据库播种

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

测试

我做到了

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

我明白了

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

观看

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;' 

我该如何解决这个错误?

【问题讨论】:

  • 我讨厌人们对其他人的帖子投反对票,而在评论中没有说任何内容以供 OP 改进。
  • 什么是watch
  • watch 将每 1 秒重新运行一次相同的命令。
  • 听起来像是watch 中的一个错误,它没有重新引用参数。
  • 在这种情况下,我想看看我的种子命令是否工作并且没有挂起。 watch 命令将显示我的表在我的数据库中的增量计数。

标签: linux macos unix psql watch


【解决方案1】:

将命令作为单个带引号的参数提供:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-19
    • 2018-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多