LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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-11-2006, 05:06 PM   #1
Xolotl
LQ Newbie
 
Registered: Oct 2006
Posts: 5

Rep: Reputation: 0
How do I save a name-date changing file?


I just set my first CRON job to run a backup using DUMP.

I want the name of my backup to be 'BKUPMMDDYY'
where:
MM= month
DD= day
YY= year

So, how can I get this pickup the appropriate date? Do I need to create an script?

Thanks.
 
Old 10-11-2006, 05:26 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
The following should work (use the variable $OUTPUTNAME as the file name):
Code:
OUTPUTNAME="BKUP`date '+%m%d%y'`"
 
Old 10-12-2006, 04:58 PM   #3
Xolotl
LQ Newbie
 
Registered: Oct 2006
Posts: 5

Original Poster
Rep: Reputation: 0
Gilead, thanks for your help.

When I ran the command from the console, it works just fine:
[root@wxyz: root] $ /sbin/dump -0u -a -f /temp/dbkup/"bkup_`date '+%m%d%y'`" /home


But, when I run it from my crontest, I get a syntax error:


MAILTO=myusername@mydomain.com
00 12 * * * /sbin/dump -0u -a -f /temp/dbkup/"bkup_`date '+%m%d%y'`" /home



This is what the cron deamon emails to me:

Syntax error: EOF in backquote substitution


Do you have any idea why is this happening?
 
Old 10-12-2006, 06:04 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
It could be that the date command isn't in the path used by the cron daemon. Can you try it with /usr/bin/date instead (or whatever the path is to date on your system)?
 
Old 10-13-2006, 06:25 PM   #5
Xolotl
LQ Newbie
 
Registered: Oct 2006
Posts: 5

Original Poster
Rep: Reputation: 0
I found several paths and try them all with no luck. I am actually running FreeBSD (6.1), but this should not be too different, right?

Thanks.
 
Old 10-14-2006, 02:21 AM   #6
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
I'd have thought the operation would be the same since it works at the command line. Can you try putting the command into a script and running the script from cron (I don't know how BSD parses the command to be run in cron)?
 
Old 10-14-2006, 02:40 AM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
And on an unrelated note: if you want to be able to sensibly
sort your backup-files later on I'd recommend ymd instead of mdy.


Cheers,
Tink
 
Old 10-20-2006, 04:28 PM   #8
Xolotl
LQ Newbie
 
Registered: Oct 2006
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks guys! I end up writing a little script and it worked just fine that way.
 
  


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
Changing the date to EST shiroh_1982 Programming 2 07-17-2006 02:06 AM
Changing the date slowly mearley Linux - Newbie 2 12-31-2004 05:07 AM
Changing the date mad_ady Solaris / OpenSolaris 3 12-19-2004 03:50 PM
Find variable in template file replace w/date+ and save as jmanjohn61 Linux - General 14 12-13-2004 06:49 AM
Date Changing mriolo Linux - Networking 1 02-24-2003 02:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:57 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