|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
get date in bash script...
Hi,
I have a bash script I run on cron.daily which dumps mysql to file, tars & gzips it, then runs a perl script to email the file to me. This works fine, but the problem is, I have loads of files with the same name, so have rename each daily backup if I want to save them in a backup folder. Is there a way of getting the script to not just name the file, but to append the date on to it as well? The current script is: #!/bin/sh /home/local/mysql/bin/mysqldump -uroot -password --opt my_db > /sqldata/my_db.sql cd /sqldata/ tar -zcvf db_daily.tgz *.sql cd /myscripts/ perl emailsql.cgi |
|
#2
|
|||
|
|||
|
RE: get date in bash script...
Try this:
#!/bin/sh /home/local/mysql/bin/mysqldump -uroot -password --opt my_db > /sqldata/my_db.sql cd /sqldata/ filename="db_daily_"`eval date +%Y%m%d`".tgz" tar -zcvf $filename *.sql cd /myscripts/ perl emailsql.cgi |
|
#3
|
|||
|
|||
|
RE: get date in bash script...
Thanks! That does the job perfectly
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Server Administration > get date in bash script... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|