| Author |
Saving files including current date variable in filename
|
|
|
| Perhaps someone can advise me how to best do the following?
I'd like a cron job on a BSD machine to once a month save the server access
log files in the following format:
access_DDMMYY.txt
If I simply type the 'date' command into the shell I get the following type
of output:
Sat Dec 15 11:41:37 GMT 2007
Does anyone have a smart procedure that can rename the file named
"access.log" into "access_151107.txt" if the command ran today for example?
| |
|
| I wrote:
> "access.log" into "access_151107.txt" if the command ran today for
I meant "access_151207.txt" of course...
| |
| Bit Twister 2007-12-15, 1:20 pm |
| On Sat, 15 Dec 2007 12:50:10 +0100, Fred wrote:
>
> If I simply type the 'date' command into the shell I get the following type
> of output:
> Sat Dec 15 11:41:37 GMT 2007
Here try this
date +%Y-%m-%d
then try
man date
| |
|
| Bit Twister wrote:
> On Sat, 15 Dec 2007 12:50:10 +0100, Fred wrote:
>
> Here try this
> date +%Y-%m-%d
> then try
> man date
>
Perfect - thanks for the tip!
| |
| s. keeling 2007-12-15, 1:20 pm |
| Bit Twister <BitTwister@mouse-potato.com>:
> On Sat, 15 Dec 2007 12:50:10 +0100, Fred wrote:
>
> date +%Y-%m-%d
> then try
> man date
Where you'll find %F.
(0) heretic /home/keeling_ date +%F
2007-12-15
For datestamping files, I prefer +%Y%m%d
--
Any technology distinguishable from magic is insufficiently advanced.
(*) http://blinkynet.net/comp/uip5.html Linux Counter #80292
- - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me.
|
|
|
|