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. |
The following should work (use the variable $OUTPUTNAME as the file name):
Code:
OUTPUTNAME="BKUP`date '+%m%d%y'`" |
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? |
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)?
|
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. |
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)?
|
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 |
Thanks guys! I end up writing a little script and it worked just fine that way.;)
|
All times are GMT -5. The time now is 10:10 PM. |