Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old July 22nd, 2002, 03:30 PM
kasafarov kasafarov is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 18 kasafarov User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 17 m 31 sec
Reputation Power: 0
Question need help with naming files in cron

I am a complete novice in Linux, so this might be a really stupid question...

I have a cron job which creates hourly backups of the database:

mysqldump database_name | gzip > /var/www/backup/data.dump.gz

What I would like to do, is to name the resulting files using timestamp, or some other naming convention, to keep backups unique. In other words, how can I use a variable for the filename in this situation?

Thanks for your help.
Kirill

Reply With Quote
  #2  
Old July 22nd, 2002, 06:57 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Just add a date like so:
Code:
/var/www/backup/`date +'%B-%d-%Y'`-data.dump.gz

BTW, why are you not using full path for mysqldump?

Reply With Quote
  #3  
Old July 29th, 2002, 03:17 PM
kasafarov kasafarov is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 18 kasafarov User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 17 m 31 sec
Reputation Power: 0
Thanks for your reply. However, your suggestion does not work. It gives me an error "too many non-option arguments." Do you know what I am doing wrong?

Thanks for your help.
Kirill

Reply With Quote
  #4  
Old July 29th, 2002, 05:13 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Show us your revision of that line. Note, you need to quote your path.

Reply With Quote
  #5  
Old July 29th, 2002, 06:24 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,632 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 12 m 33 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
And a clarification- those are backticks, not single quotes. Backticks are on the same key as the ~

Reply With Quote
  #6  
Old July 31st, 2002, 10:09 AM
kasafarov kasafarov is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 18 kasafarov User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 17 m 31 sec
Reputation Power: 0
Here is the complete line from the file:

mysqldump database_name | gzip > /var/www/backup/`date +'%B-%d-%Y'`-data.dump.gz

If I put quotes around the path, it stops executing date command. I know I am probably missing something very simple.

Can you guys help, please?

Kirill

Reply With Quote
  #7  
Old July 31st, 2002, 01:27 PM
ghatzhat ghatzhat is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 361 ghatzhat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 5 sec
Reputation Power: 7
i expect it's just a typo or something...

here's what I have - very similar to freebsd's suggestion:

/usr/local/mysql/bin/mysqldump --add-drop-table --add-locks msgboard > /webhome/sql/msgboard`date +%y%m%d`.sql
__________________
Little more than a playground for the bugs that live beneath us...

Reply With Quote
  #8  
Old July 31st, 2002, 04:15 PM
kasafarov kasafarov is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 18 kasafarov User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 17 m 31 sec
Reputation Power: 0
I figured it out.

Thanks for the help, though!

Reply With Quote
  #9  
Old July 31st, 2002, 08:55 PM
StealthElephant's Avatar
StealthElephant StealthElephant is offline
Shes dancing (obviously)
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2002
Location: the far side
Posts: 526 StealthElephant User rank is Corporal (100 - 500 Reputation Level)StealthElephant User rank is Corporal (100 - 500 Reputation Level)StealthElephant User rank is Corporal (100 - 500 Reputation Level)StealthElephant User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 h 14 m 22 sec
Reputation Power: 8
cant you just use the \ for spaces and get rid of the quotes altogether?
__________________

microsofts butterfly is their way off telling u their systems have a **** load of buggs
Advocating Linux Guide
Lesbian Linux
Great & Practical Computer Books

like the links?

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > need help with naming files in cron


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway