LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-27-2008, 05:54 AM   #1
leonids665
LQ Newbie
 
Registered: Jun 2007
Posts: 3

Rep: Reputation: 0
check file oldness


I have a backup script:
Code:
##export day=$(date +%a)
##if [ $day = "Sat" ] || [ $day = "Sat" ]; then
##   rm -f /backup/*
##fi

export date=$(date +%T-%Y-%m-%d)
tar cvf - /srv | gzip > /backup/srv-$date.tar.gz
Now it.s deleting old files in saturdays, but how to make it, that it.s deleting only files older then seven days?
 
Old 02-27-2008, 12:28 PM   #2
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 73
Moved: This thread is more suitable in the Programming Forum and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 02-27-2008, 01:20 PM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
You can use find to narrow down the "oldness" and then delete the files it comes up with.
ta0kira
 
Old 02-27-2008, 02:28 PM   #4
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Code:
find /path/to/files -mtime +7 -type f -exec rm -f {} \;
 
Old 02-27-2008, 04:52 PM   #5
leonids665
LQ Newbie
 
Registered: Jun 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks a lot jim. It.s works and that, what i needed!!!
 
  


Reply

Tags
backup, script


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
How to write crontab to check file size and all file in a directory? modpriest Linux - Newbie 1 02-14-2008 06:48 AM
Check to see if a file has a certain character in it krock923 Programming 2 11-25-2004 03:30 PM
samba file check steve_d555 Linux - Networking 5 04-12-2004 02:17 PM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 02:10 AM
check file in use pangfai Linux - Networking 1 07-09-2002 01:29 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration