Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-30-2006, 12:44 PM   #1
LQ Newbie
Registered: Oct 2006
Posts: 17

Rep: Reputation: 0
save info in dated files

I've got cron running a little script that dumps a mysql table into a file. I would like to append a timestamp to the filename so that files do not overwrite each other. Is there a simple way to do that?

/usr/local/mysql/bin/mysqldump -uuser -pnone --opt test weight --socket=/var/lib/mysql/mysql.sock --add-drop-table > test_table_dump.sql
Old 10-30-2006, 12:50 PM   #2
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Yes there is. Like this (quoting your own codepiece):
datevar=$(date +"%F")
/usr/local/mysql/bin/mysqldump -uuser -pnone --opt test weight --socket=/var/lib/mysql/mysql.sock --add-drop-table > "test_table_dump_$datevar.sql"
I'm on XP machine now so can't test that but it ought to work. You might want to test with an empty text file first, to make sure it works, but that's the idea. For more information and fancy examples, take a look at, it's a good site and probably has an example there that does the above, takes a date and makes a variable out of it.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automated FTP script to grab ONLY newest dated files kaiserbeto Linux - Newbie 4 10-20-2006 03:46 AM
script for display a clock from dated images osio Programming 0 01-14-2006 11:38 AM
Dated 486 Laptop + Linux nemo3383 Linux - Laptop and Netbook 5 03-30-2004 12:33 AM
/etc/hosts won't save my info... nuzzy Linux - Networking 2 05-01-2003 08:36 PM
Why are all IPTables guides out-dated? Can this be done..? Grim Reaper Linux - Networking 1 01-25-2003 08:17 AM

All times are GMT -5. The time now is 05:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration