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 06-25-2008, 02:34 PM   #1
chasegger
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Rep: Reputation: 0
move a file to same location with a different extention


I have a rsyncd.log file that I would like to move on a weekly basis.
If possible I would like to take this rsycnd.log file and move it to same location with the current MMDDYY extention

ex: mv rsyncd.log rsyncd.log.062508 << How can I script to add current
date timestamp.

Thank you
 
Old 06-25-2008, 03:06 PM   #2
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Rep: Reputation: 44
you can add this to where you want the date `date +%b%d_%H%M%P_%Y`


play around with the format but that will give you Jun25_1605pm_2008 format Monthdate_time_year
 
Old 06-25-2008, 03:08 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
mv rsyncd.log rsyncd.log.$(date \+\%Y%m%d)
 
Old 06-25-2008, 03:32 PM   #4
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
In some distributions there is a package you can install which does exactly this.
On Gentoo it is called "logrotate" - Debian has it too as well as probably many others.
Moves and compresses the logs as you configure it and can mail it too...
 
Old 06-25-2008, 06:21 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Put your distro in your profile, so we can see it. Logrotate is designed for sort of this task and most distros have it.
 
  


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
JRE will not move to location so can install... linexnal Linux - Software 4 07-17-2007 02:08 PM
how to open file with stp extention in SuSE 10.1 riba43 SUSE / openSUSE 2 07-24-2006 11:55 AM
what's find the extention of a file in linux? mcshen Linux - General 20 02-28-2005 01:16 PM
.sh install file extention matt Linux - Newbie 7 09-09-2004 03:37 AM
unpacking a (.sh) file extention. troycus Linux - Newbie 2 10-07-2003 09:52 PM

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

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