我正在使用CentOS 6.6。 我正在尝试设置一个crontab。 我做了一个手动执行的.sh脚本。 命令如下:
mysqldump --skip-lock-tables --single-transaction --hex-blob --flush-logs --master-data=2 -u root -p'password' database1 > database2.sql
但是,当我尝试在/ etc / crontab文件中设置它时,它不会运行。 这里是crontab文件的内容。
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed * * * * * root /home/user/public_html/default1.sh
另外,我想这个脚本在目录中执行
/home/user/public_html
我的脚本叫做default1.sh,我把它放在/ home / user / public_html目录下。
我的目标是每分钟在/ home / user / public_html中以root用户身份执行此命令(或现在的default1.sh脚本)。
有几件事你需要检查:
x (至less对于用户)是可执行的。 mysqldump在crontab PATH 。 否则,在脚本中指定绝对path。 另外,-u root是错误的语法。 应该是 – AFAIK。
无论如何,尝试通过添加logging您的cron条目
>> /somefile.log 2>&1
到cron线