LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-29-2004, 12:43 PM   #1
rstoutmna
LQ Newbie
 
Registered: Dec 2004
Posts: 4

Rep: Reputation: 0
using bash in cron to get the date in filename


Can anyone help me with a mysqldump to a windows share that will allow me to save the name of the file as the current date using cron? It will dump to a file with a static name but I would rather it not write over a previous file. Thanks.
 
Old 12-29-2004, 02:39 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Code:
#!/bin/bash

DUMPFILE="mysqldump_$(date '+%Y-%m-%d').sql"
mysqldump --opt --databases "YourDatabaseName" >"$DUMPFILE"
Read "man date" for more options on the format of the date. I used "<year>-<month>-<day>" here because that'll sort better.
 
  


Reply



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
bash returns ambiguous redirect with date in filename rstoutmna Programming 5 09-13-2011 07:37 PM
logrotate with date in filename ptp Linux - Newbie 1 04-14-2011 10:55 AM
Script add date to filename amphion Linux - Newbie 2 06-02-2004 07:12 AM
use date as output filename? wijnands Linux - Newbie 1 05-12-2004 03:39 PM
how to add date to filename x2000koh Programming 1 07-08-2003 09:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:19 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration