Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-25-2008, 02:34 PM   #1
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
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
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
mv rsyncd.log rsyncd.log.$(date \+\%Y%m%d)
Old 06-25-2008, 03:32 PM   #4
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
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,774

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:12 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration