wsp*_*irs 1 python bash cron rethinkdb
我正在尝试设置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
Run Code Online (Sandbox Code Playgroud)
我手动运行时脚本运行正常.但是,当尝试从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/
Run Code Online (Sandbox Code Playgroud)
它似乎是一个Python环境问题,但我无法弄清楚如何使它快乐...想法?救命!
小智 6
当您从该backup.sh脚本运行它时,它可能在没有正确的PATH设置的情况下运行,并且找不到PATH rethinkdb-dump.
首先,让我们找出它的位置 rethinkdb-dump
which rethinkdb-dump
(on my pc, I guess it's very different on your pc)
/usr/local/bin/rethinkdb-dump
Run Code Online (Sandbox Code Playgroud)
现在,尝试将PATH附加到您的脚本 backup.sh
#!/bin/bash
export PATH="$PATH:/path/to/folder/contain-rethinkdb-dump"
# The rest of your script normally
Run Code Online (Sandbox Code Playgroud)
以我的例子为例,我会这样说:
export PATH="$PATH:/usr/local/bin"
Run Code Online (Sandbox Code Playgroud)
我认为你的rethinkdb-dump正常bin文件夹外(/ usr/bin,/ usr/local/bin等)