Linux Bash Date Characters
I want to have a system where when I backup my mysql database. The script would save the filename according to its date.
so mysql_backup_full-2005-23-12.sql mysql_backup_full-2005-24-12.sql mysql_backup_full-2005-25-12.sql ...and so on but you see how the date of the file is different (because it is backed up on a certain day) how would I make the name so that when the backup_mysql file is executed it would save the filename as today's date.. thanks |
set a date variable in your script
date='date -y -d' (check out the flags you need, these are just a random example!!) then write the outgoing filename like this: mysql_backup_full-"$date".sql |
date=`date +%Y-%d-%m`
Put that somewhere in your script, and, as linmix said, use $date wherever you want the date, in your specified format, to show up. |
All times are GMT -5. The time now is 12:42 AM. |