1

I'm using the following in crontab:

36 22 * * * root mysqldump -u CENSORED -p CENSORED server | gzip > /home/samp/samp03/scriptfiles/sql-backup/server_backup_`date + \%d-\%m-\%y`.sql

but I'm getting the following error in mail (I want to keep the separators [-]):

date: extra operand `%d-%m-%y'

  • Suggest using mysql_config_editor so you can set-up a cron job without including the login and password. – Tigger Jun 24 '17 at 22:57
  • I'd rather use it this way, how can I keep the separators and make it work? – Nutz Jun 24 '17 at 22:58
  • There should not be a space after the + in the date command. – camh Jun 25 '17 at 6:22
0

Remove the space between the + and the format specification in the invocation of date:

date +'\%d-\%m-\%y'

When you put a space after the +, date gets the two arguments + and '\%d-\%m-\%y'.

Since you're using GNU date, which doesn't expect any other command line arguments after a format specification, you get the error message "extra operand" for the string '\%d-\%m-\%y'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.