LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 10-30-2006, 11:44 AM   #1
va1damar
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?

Code:
#!/bin/sh
/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, 11:50 AM   #2
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Yes there is. Like this (quoting your own codepiece):
Code:
#!/bin/sh
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 linuxcommand.org, 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.
 
  


Reply


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 02:46 AM
script for display a clock from dated images osio Programming 0 01-14-2006 10:38 AM
Dated 486 Laptop + Linux nemo3383 Linux - Laptop and Netbook 5 03-29-2004 11:33 PM
/etc/hosts won't save my info... nuzzy Linux - Networking 2 05-01-2003 07:36 PM
Why are all IPTables guides out-dated? Can this be done..? Grim Reaper Linux - Networking 1 01-25-2003 07:17 AM


All times are GMT -5. The time now is 08:21 AM.

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