在CentOS中为XAMPP运行MySQLdump [英] Running MySQLdump for XAMPP in CentOS
问题描述
希望我将其发布在正确的论坛中。。
Hopefully I am posting it in the right forums..
基本上,我正在尝试运行一个脚本来执行MySQL数据库转储,该脚本在我运行时可以正常运行
Basically, I am trying to run a script that will do a MySQL database dump which works when I run it manually, but crontab doesn't seem to run that particular script for some reason.
我的crontab就是这样设置的(出于测试目的,每分钟运行一次):
My crontab is setup as such (for testing purposes, running every minute):
* * * * * /opt/lampp/htdocs/xyz/backup/backup.sh
脚本的设置如下:
#!/bin/bash
# Script to backup the database
/opt/lampp/bin/mysqldump -u root xyz > backup_$(date +%Y%m%d).sql
echo " backup_$(date +%Y%m%d)" > /opt/lampp/htdocs/xyz/backup/log.txt
我知道脚本会运行,因为log.txt已创建。但是由于某种原因,没有生成SQL文件。我也知道该行
I know the script runs, because the log.txt is created. But for some reason, no SQL file is generated. I also know that the line
/opt/lampp/bin/mysqldump -u root xyz > backup_$(date +%Y%m%d).sql
可以正常工作,因为如果我在命令行上运行它。
works because it generates the file if I run it at the command line.
任何帮助非常表示赞赏!
推荐答案
因此,当crontab运行shell脚本时,backup_(date).sql文件实际上保存在/ root文件夹下。
So when crontab runs the shell script, the backup_(date).sql file is actually saved under the /root folder.
手动运行shell脚本会将SQL文件放置在shell脚本所在的位置。
Running the shell script manually places the SQL file where the shell script is.
这篇关于在CentOS中为XAMPP运行MySQLdump的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!