General :: Delete Old Files Older Than 7 Days?
Sep 18, 2009find -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 Repliesfind -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 RepliesI 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 RelatedI 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 RelatedI'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{}
Can I delete files in trash that is older than 10 days with a terminal command?
View 3 Replies View RelatedI 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 RelatedI 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.
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 RelatedI 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 RelatedI'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
Possible Duplicate:How do I delete files greater than a certain date on linux How to delete all files in current directory and it`s sub directories older than one year ?
View 2 Replies View RelatedSeem 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]...
I want to capture a mms stream daily. All works well with that, but I also want to delete any mpg files that are captured from the stream that are more than 7 days old. Will this command work?
Code:
#!/bin/bash
find /mnt/tera/all_video/thai3 -ctime +7 -name "*.mpg" -exec rm -f {} ; -ls > /var/log/thai3.log 2>&1
[code]....
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 RelatedI have server running ubuntu. There is folder /var/netflow and I have there files, which creates every 5minutes new ones(monitoring traffic on network). And I need to delete files older than 6 months manually. Can you help?
View 2 Replies View RelatedI use this below script to delete the logfiles older than 1 day .find /home/cie101/madhu1 -mtime +1 -exec rm {} ;and it doesnot work properly.
View 12 Replies View RelatedI 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 ;
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]...
I want Firefox to delete history after several days. Can I configure it this way?"Remember my browser history for at least..." is not the option which does it, right?
View 11 Replies View RelatedCommand to find all of the files which have been accessed within the last 30 days?
View 1 Replies View RelatedI`m totally new to linux, in fact I`m a windows adminscenario:I need to run a script that will automatically move 30 days old files from particular folder to a particular folder.
View 3 Replies View RelatedI have a directory there are many files are writing to it , I would like to write a script to do that , can please provide the advise .
archive all files to one single file in every 30 days , and then remove these old files .
I used following command to sort one day older log files
Quote:
find /opt/TimesTen/tt_transaction_log/ -name "mtsDB.log*" -mtime +1 -print
following are log files which are existing, I have to delete one day older files from this location but when use above mentioned command it won't print one day older files, as i understand "-mtime" modified time, "+1" means one day older. am i correct?
Code:
-rw-rw-rw- 1 ablddb dba 268435456 May 30 17:11 mtsDB.log126985
-rw-rw-rw- 1 ablddb dba 268435456 May 30 17:17 mtsDB.log126986
-rw-rw-rw- 1 ablddb dba 268435456 May 30 17:23 mtsDB.log126987
[code].....
How can i print one day older logfiles?
on my site now I'm using cache and need me cron script that will delete files older than 1 hour I have feature in my kloxo control panel just need me the command .
View 2 Replies View RelatedWhen I turn on my computer, because of frequent updates it will display several versions of Ubuntu 10.10 that I can choose from. I wonder if it is possible to delete some of the older versions and how. I think having several versions of Ubuntu uses up a lot of space in the hard drive.
View 4 Replies View Relatedhow to find a file with a ctime older than. let's say, 5 seconds? What I would like to do is to move all "new" files in a specific folder but not files that has not yet finished uploading.
View 1 Replies View RelatedI am trying to write a simple back up script in python where I try to list the files that are 24 hours old in specific directories that I would choose.I read the manual of find and used
find . -mtime 1 > log.dat
to get the list of files in the log.dat however I also get the path information in that list as such
./hpc06MatlabCodes/2011/Apr/3dBoxModel
./hpc06MatlabCodes/2011/Apr/3dBoxModel/vfluidIrca10.dat
./hpc06MatlabCodes/2011/Apr/3dBoxModel/vLRecoveredSystem.mat
is there a way to exclude the directories and only get the files list.
I am trying to dl the files located here: http://good.net/dl/bd/CCCamp-2007/video/m4v/ using wget.
Now when I use the command wget -r -A .m4v http://good.net/dl/bd/CCCamp-2007/video/m4v/
I get the just a bunch of filefolders, but no files, ex."cccamp07-de-1845-Freifunk_und_Recht.m4v" but its a folder.
If I am logged in as root in a linux system and I run command rm -rf on / folder, should it remove all the files? also the kernel?
View 4 Replies View RelatedI 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