General :: Command To Copy Files Older Than <n> Days Keeping Dir Structure?

Jul 6, 2010

I'm trying to truncate a postfix Maildata directory for one of our users. I want to be able to move any files older than <n> days to a new location, but also copying the relevant directory structure. This should be doable in the one comman. I've used find to locate the files, and mv to move them, but I can't figure out how to build the directoryt structure on the fly in the new location.

This is what I have so far:

Code:
find /Maildata/editor -mtime +42 -type f -exec mv -v {} /EditorEmailOld/ ; > ~/editor.txt

View 4 Replies


ADVERTISEMENT

Ubuntu :: Delete Files In Trash That Is Older Than 10 Days With A Terminal Command?

Sep 27, 2010

Can I delete files in trash that is older than 10 days with a terminal command?

View 3 Replies View Related

General :: Shell Script To Copy All Folders Older Than 7 Days?

Mar 16, 2011

I want to make the script to copy all folders which older than 7 days from Linux server to Windows server by Samba. And make it automatically by using cron

View 4 Replies View Related

General :: Delete Files When It's Older 30 Days?

Jan 6, 2011

I am trying to put together ksh shell and I am new with writing scripts.How do you write a command to delete any files if it's 30 days old and also it's not currently being locked?

View 10 Replies View Related

General :: Delete Old Files Older Than 7 Days?

Sep 18, 2009

find -type f /path/* -mtime +7 -exec rm {} ;Is this the best way to delete only files (not directories) within /path that are older than 7 days? or is there a better way?

View 3 Replies View Related

General :: Copy Files Less Than 7 Days Old?

May 6, 2011

I have searched for a way to copy file less than X days old and I found this:http://www.howtogeek.com/howto/ubunt...days-on-linux/ The syntax for deleting files less than 7 days old would be like this:find /path/to/files* -mtime -7 -exec rm {} ;I would like to copy the files to mntas, and I'm not sure what the syntax should be.ould this work?find /path/to/files* -mtime -7 -exec cp {} mnt
as ;

View 3 Replies View Related

Programming :: Delete Files Older Than 7 Days?

Jan 3, 2011

I am new to unix, I am looking for a script to delete files older than 7 days but i also want to exclude certain directories (like arch,log .....) and also some files with extensions ike .ksh, .ch, ..............) in directories and sub directories

View 4 Replies View Related

CentOS 5 :: Delete Files Older Than 7 Days?

Jan 26, 2010

I've been trying to delete all files older than 7 days in a directory temp1.I have try different ways but nothing happend:

find /temp1/* -mtime +7 -exec rm rf
find . -mtime +7 -exec rm rf
find /temp1/* -mtime +7 -print -exec rm{}

View 13 Replies View Related

Ubuntu Servers :: Rotation Part Is Not Removing Files Older Than 90 Days?

Dec 3, 2010

Seem my rotation part is not removing files older than 90 days. Anybody know what is wrong?

Code:
#!/bin/sh
#navigate to the desired backup location
cd /public/backup/linux
#dump the MySQL entirely, output file is dated
mysqldump -u root -pmt1jxz68f2 --all-databases > "`date +%Y%m%d`.sql"
#backup the web folder

[Code]...

View 1 Replies View Related

Server :: Script To Delete Files Older Than X Days Fstab Has Noatime Enabled?

Jul 26, 2011

I have set up a simple find and delete script for files older than X days. The problem is that some of the files that are send in this share are transfered from an archive server and creation/modified date remains the same when copied and the age of them could be a year ago or older and they get deleted over night by the script.For performance reasons the raid is mounted with noatime in fstab.Do you see any solution to this problem except enabling atime?I'm thinking at some more advanced script that writes the list of added files once a day and marks them for deletion after some time.

View 2 Replies View Related

General :: Command To Find All Of The Files Which Have Been Accessed Within The Last 30 Days?

May 14, 2010

Command to find all of the files which have been accessed within the last 30 days?

View 1 Replies View Related

General :: Renaming A Bunch Of Files Using For-structure And The Mv Command?

Feb 3, 2010

Basically I need to rename a bunch of .doc files using the for-structure and the mv command (w/ wildcards) in bash. I guess this would be a bit easier if I'd use the rename command, but since this is a school assignment of sorts I need to use for & mv. The .doc files are named "1filename.doc", "2filename.doc" etc. And I've got to rename them to "aaa_1filename.doc", "aaa_2filename.doc", "aaa_3filename.doc" and so on. Tried to dabble quite a bit with the for and mv commands, basically just got a bunch of errors. Every damn time. For 2 hours. The most common error was "mv: missing destination file operand after ..."

View 6 Replies View Related

General :: Run Rsync On Server A To Copy All Files From Server B When They Are Newer Than 7 Days

Jun 14, 2011

I want to run rsync on server A to copy all files from Server B when they are newer than 7 days.(find . -mtime -7) I don't want to delete the files on Server B.

View 2 Replies View Related

General :: Script To Compress A Directory And Then Delete Older Than 7 Days

Feb 3, 2010

I have been trying to write a script that will take a directory, for example /accounts compress it into a .tar file with the filename containing the date of compression, for example accounts030210.tar and then place that file into a directory called /archive

I also want the script to delete files in /archive that are older than 7 days.

View 3 Replies View Related

General :: Delete Backups Older Than 7 Days Through Shell Script?

Jul 15, 2011

I am having my own testing server in which mySQL database will be backed up daily. in the format mysql_backup_dd/mm/yy.tar.gz in my home folder I need to setup a cron job to delete the backups older than 7 days.how to do this.

View 3 Replies View Related

OpenSUSE Install :: Keeping An Older Kernel

Feb 4, 2010

I used to keep a back level kernel on all my systems along with the latest upgraded kernel. How is that done using Yast/zypper? I don't see an option to keep the older version.

View 5 Replies View Related

General :: Copy Mutiple Files Over Scp In One Command?

Mar 4, 2010

I have to transport a lot of files from one pc to another (both Linux). I would like to use scp for that, but scp only allows for transferring one file at a time. How can I do this?

I have No possibility to use rsync or any other protocol No possibility to use passphrase free certificates (but have a certificate with a passphrase) A list of files to transfer and a list with the destination path of the files on the other server The files are spread out over a lot of directories, and not all the files in the directories I want to copy If possible I would like to gzip and ungzip transparently to save bandwidth!

View 3 Replies View Related

General :: Copy Directory Into Another Preserving Specific Structure?

Jul 20, 2011

I would like to find the command that copy my eclipse options to another workspace code...

It doesn't work, and it could be source of error to write the path .metadata/.plugins manually. It certainly a better idea to create a complete script ?

View 1 Replies View Related

General :: Find Directory Older Than X And Mv Directory With Sub Files Command?

Jul 13, 2011

I'm quite new to linux but I have configured a simple ftp server and it's working great. I have a FTP-Shared folder with upload and download subfolders. Under upload's and download's I have identical category subfolders like mp3's, movies, software etc. in both. As the guy's upload, I would like to create a line crontab where I can move all the content under /FTP-Shared/upload/mp3/* older than 14 day's to FTP-Shared/downloads/mp3/ recursively (Like in cp command), but the timestamp must be searched on the first directory and not sub files example: /mp3/Club Dance/CD1/Hallo world.mp3This is how far I got:[root@clients ~]# /usr/bin/find /FTP_Shared/upload/Mp3s/ -depth -mindepth 1 -mtime +14 -type d -exec mv -f {} /FTP_Shared/download/Mp3s/ ;This command moves the directory and files, but it is not recursively

View 4 Replies View Related

General :: Mounting Fedora ISO DVD And Then Copy The Full DVD Structure Locally

Sep 16, 2011

I need to recreate in a local folder called /distro/fedora/ the full directory tree (including eventually hidden files, symlinks, etc.) contained in the .iso file just downloaded (Fedora-15-i686-Live-Desktop.iso).

I understand I can mount the ISO image using something like this:

mount -ro loop /path/to/image.iso /mnt

but then, which would be the best way to get a copy exact of what I see underneath /mnt in to /distro/fedora ?

cp, tar, clobber?

View 1 Replies View Related

Programming :: Write Synatax To Delete Stuff Older Than 8 Days?

Mar 31, 2011

I got this part from my script working that it will delete a folder is from 8 days agoEightDaysAgo=`(date --date="8 days ago" +%d-%m-%Y)`rm -rf $EightDaysAgoTarHowever I need to remove files that are older than 8days for example if the script is'nt run for a day it will remove both the 9th and 8th day one not just the 8th day one. If I'm making any sense lol

View 3 Replies View Related

General :: Copy File Recursively Ignoring Destination Directory Structure?

Jul 8, 2011

I have the following content on the source directory:

source/foo.txt
source/bar/another_file.txt
source/bar2/and_another.txt

I want copy those files to a destination directory which, after copy, shall look like this:

destination/foo.txt
destination/another_file.txt
destination/and_another.txt

How can I do this? It seems that "cp" lacks such an option

View 1 Replies View Related

General :: Copy The Contents Of A Txt File To Other Txt Files (with Similar Names) By Cp Command?

Jul 2, 2010

Code:
cp -r aa123.h aa*.h
results in
Code:
cp: target `aa456.h' is not a directory

Yes I read man page cp (1p). There is something written there about it, I couldn't understand though.

View 7 Replies View Related

General :: Command Line - Automating A Task - Copy All Subdirectories And Files From One Directory To Another

Jun 10, 2010

I need to copy all subdirectories and files from one directory to another ever 5 minutes or so, with the old data automatically being overwritten with the new data. I'd also like this to run at startup. Is there any way this can be done? If so, what program would I need to schedule the automation and what is the command line I would need.

View 2 Replies View Related

General :: Using Gnokii Utility - Copy Command As Copying Files To Home Is Not Allowed

Mar 16, 2011

iam trying to send sms using gnokii utility in linux firstly i did sudo apt-get install gnokii after that i got a gnokiirc.gz file in /usr/share/doc/gnokii/sample/gnokiirc.gz file here after that i did gunzip gnokiirc.gz then i transferred my file from the /usr/share/doc/gnokii/sample to home directory by using copy command as copying files to home is not allowed so i used sudo sudo cp gnokii /home after that i changed the port=/dev/ttyUSB2 and model=AT in the gnokiirc file in the home directory and then i wrote gnokii --identify

[Code]....

i followed as in the [URL] and [URL] and except this "Note that you will need read/write permissions on whatever serial port you specify in .gnokiirc."(iam confused what is my serial port is it ttyUSB2)

View 7 Replies View Related

General :: Copy A File With Certain Name Pattern For Which Exact Place In Complex Directory-structure Unknown?

Sep 19, 2011

I want to copy all files with the name XYZ* into one folder. The problem is that the files are in different subfolders and that not even the depth of the folder structure is the same for all files. Luckily, at least each file has a unique name.

Of course, I thought about the cp command but I guess the depth of the folder structure needs to be the same for this to work.

View 3 Replies View Related

General :: Find Command With -mtime +15 Or -15 Days?

Feb 2, 2011

I am writing a bash script which includes the find (and rm command with exec) command the options -mtime -15 or +15 so that files older 15 days must be deleted from the home directory. I think that -mtime +15 should be ok, but in which case does the option -mtime -15 really come in handy?? go back 15 days until today's date?

View 1 Replies View Related

Ubuntu :: Command Line To Copy Files From One Location To Another / Retain Source Files Group / User?

Feb 20, 2011

Is there a method at the command line to copy files from one location to another and retain the source files group and user?I'm migrating some MySQL files from one machine to another.I want to back-up the original files in the directory presently. They have owner:group of mysql, some have owner:group root:mysql and so on. To copy them under cli or Nautilus everything changes to root for I execute sudo cp or gksudo nautilus and copy via gui.

Since it is MySQL data I could simply do a dump of the database and restore it on the other machine. But there's about 20 db's and I want to do this via a copy for it will be faster - at least that is what I think.

View 5 Replies View Related

General :: Finding Files Exactly 7 Days Old?

Apr 19, 2010

i am a newbie in linux ,i am writing a bash script to identify the files which are exactly 7 days ( a week old) i tried this command find /var/backup -mtime +7 -exec ls -d {} ;but this gives me even the files which are older than 7 days

[root@proxy access]# find . -mtime +7 -exec ls -d {} ;
./access.log.1.gz
./access.log.2.gz

[code]...

View 3 Replies View Related

General :: Copy Certain File Types Recursively While Maintaining File Structure On Destination?

Jun 14, 2011

I have just been bothered by a fairly small issue for some time now. I am trying to search (using find -name) for some .jpg files recursively. This is a Redhat environment with bash.

I get this job done though I need to copy ALL of them and put them in a separate folder BUT I also need to keep the order intact after copying.

For e.g - If I get a JPG file under /home/usr/new/1/ then the destination also needs to be /test/old/new/1/.

At the moment, I am simply putting all files under /test/old/ and I can't somehow get the later /new/1/ folder path created under /test/old/

I understand this could well be done using while OR if else loop, though if someone can just guide me with a hint, I would be really grateful.

I will complete the rest of the steps and was asking here since I am still not comfortable with the shell/bash scripts yet and planning to be really good at it over the next couple of months.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved