如何在 postgres 中使用 shell 脚本触发 VACUUM 命令 [英] How to fire VACUUM command using shell script in postgres

查看:51
本文介绍了如何在 postgres 中使用 shell 脚本触发 VACUUM 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的shell脚本

Here is my shell script

    #!/bin/bash
    psql --host=127.0.0.1 --port=5432 --dbname=SIEM --username=dbauser
    vacuumdb --analyze --verbose --table 'vuln' SIEM

但它不能正常工作并给出错误:

but its not working fine and gives error as:

   linux-lxh4:/home/gaurav # ./script.sh 
   psql (9.2.5)
   Type "help" for help.

   SIEM=# \q
   vacuumdb: could not connect to database root: FATAL:  Peer authentication failed for user "root"

Edit1:我使用了这个代码:

I used this code :

   psql --host=127.0.0.1 --port=5432 --dbname=SIEM --username=dbauser
   VACUUM FULL VERBOSE vuln 

这里是错误:

   ./script.sh: line 4: VACUUM: command not found

推荐答案

来自 Postgres VACUUM 文档

管理命令被称为 vacuum 而不是 vacuumdb.

the administrative command is called vacuum not vacuumdb.

我这里没有 psql 但应该是

I don't have a psql here but it should be

#!/bin/bash
psql --host=127.0.0.1 --port=5432 --dbname=SIEM --username=dbauser
-c 'VACUUM VERBOSE ANALYZE vuln'

这篇关于如何在 postgres 中使用 shell 脚本触发 VACUUM 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆