【问题标题】:Problems running rethinkdb-dump from cron从 cron 运行 rethinkdb-dump 的问题
【发布时间】:2015-12-23 11:13:18
【问题描述】:

我正在尝试设置 rethinkdb 的定期备份,但一直遇到问题。你如何设置 rethinkdb-dump 从 cron 运行?

这是我的脚本:

$ cat backup.sh 
#!/bin/bash
NOW=$(date +"%Y-%m-%d-%H-%M")

/usr/bin/rethinkdb dump -e my_db -f /root/db_backup/$NOW.tar.gz

当我手动运行脚本时,它运行得很好。但是,当尝试从 cron 运行它时它不起作用,我在stderr 得到以下信息:

Error when launching 'rethinkdb-dump': No such file or directory
The rethinkdb-dump command depends on the RethinkDB Python driver, which must be installed.
If the Python driver is already installed, make sure that the PATH environment variable
includes the location of the backup scripts, and that the current user has permission to
access and run the scripts.
Instructions for installing the RethinkDB Python driver are available here:
http://www.rethinkdb.com/docs/install-drivers/python/

这似乎是 Python 环境问题,但我无法弄清楚如何让它快乐......想法?救命!

【问题讨论】:

    标签: python bash cron rethinkdb


    【解决方案1】:

    当您从该 backup.sh 脚本运行它时,它可能在没有正确 PATH 设置的情况下运行,并且找不到 rethinkdb-dump 的 PATH。

    首先,让我们找出rethinkdb-dump在哪里

    which rethinkdb-dump
    (on my pc, I guess it's very different on your pc)
    /usr/local/bin/rethinkdb-dump
    

    现在,尝试将 PATH 附加到您的脚本 backup.sh

    #!/bin/bash
    export PATH="$PATH:/path/to/folder/contain-rethinkdb-dump"
    # The rest of your script normally
    

    所以以我为例,我会这样说:

    export PATH="$PATH:/usr/local/bin"
    

    我认为您的 rethinkdb-dump 位于正常 bin 文件夹之外(/usr/bin、/usr/local/bin 等)

    【讨论】:

      【解决方案2】:

      windows 的 python 安装程序在此处的子文件夹中安装脚本和包:

      $env:APPDATA\Python\Python37 用于 powershell

      %APPDATA%\Python\Python37 用于 cmd

      cd这个目录查看/Scripts/site-packagespip packages

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-02-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-17
        • 2013-02-05
        • 1970-01-01
        • 2021-03-04
        相关资源
        最近更新 更多