shell
dbbackup.sh:
<code>mysqldump -uname -ppassword dbname | gzip > /www/web/mysqlbackup/xiangyanghua`date +%Y-%m-%d_%H%M%S`.sql.gz </code>
crontab
<code>37 22 * * * root /www/web/mysqlbackup/dbbackup.sh</code>
Please tell me what’s wrong.
shell
dbbackup.sh:
<code>mysqldump -uname -ppassword dbname | gzip > /www/web/mysqlbackup/xiangyanghua`date +%Y-%m-%d_%H%M%S`.sql.gz </code>
crontab
<code>37 22 * * * root /www/web/mysqlbackup/dbbackup.sh</code>
Please tell me what’s wrong.
1. Run the command directly, you can do it without
2. Is the crontab service turned on?
1 The crontab task will be executed using the current user identity, adding root is useless;
2 Execute the command manually to see if it succeeds or if there are any other errors;
3 Add it to your dbbackup.sh script Output the log content to a file, such as adding
<code>echo $(date)--start >> /tmp/xxx.log </code>
This method is used to determine whether the script has been executed and at which step the error occurred;
4 The standard output and error output of the execution are added to the crontab task
<code>37 22 * * * /www/web/mysqlbackup/dbbackup.sh > /tmp/dbback.log 2>&1 </code>
5 Executable permissions for scripts
6 If mysqldump is installed from source code, you need to pay attention to the path environment variable. Crontab may not be able to read the path, so mysqldump should write the absolute path in the script;