2015-09-25 70 views
1

我正在嘗試安裝rethinkdb的定期備份,但仍然遇到問題。你如何設置rethinkdb-dump從cron運行?從cron運行rethinkdb-dump的問題

這裏是我的腳本:

$ 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環境問題,但我無法弄清楚如何使它快樂..想法?幫幫我!

回答

6

當您從該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住在外面沒有rmal bin文件夾(/ usr/bin,/ usr/local/bin等)