1
votes

I am trying to output a file in the format of filename-12-12-16.sql using Cron Job available in the HostGator cPanel. I can currently output the file name without the date added using this code:

mysqldump -uuser -ppassword --databases dbase > filename.sql

I did some searches on how to add dynamic dates to files and so I used the code below:

mysqldump -uuser -ppassword --databases dbase > filename$(date +%Y-%m-%d).sql

But what I see happen is that the code stop executing at the first '%' symbol so I will get errors such as

/bin/sh: -c: line 0: unexpected EOF while looking for matching `)'

/bin/sh: -c: line 1: syntax error: unexpected end of file

What should I do in this case to get a dynamic date added to the file name?

1

1 Answers

1
votes

I have found the solution for those that have this issue:

mysqldump -uuser -ppassword --databases dbase > filename$(date +\%Y-\%m-\%d).sql

Simply add backslashes before the '%' symbols.