LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 04-21-2006, 11:04 AM   #1
Azhrarn
Member
 
Registered: Aug 2005
Location: Europe
Posts: 63

Rep: Reputation: 15
Deleting folder content


Heya,
I have a folder my users use to exchange files.
Of course nobody cleans up, so I m looking for a script that deletes files after 24 hours.

Problem is when a file is put there it retains its original creation date, so in order to use a

find /bla/temp -type f -mtime -exec

kind of command, I d have to touch the new arrivals.

Any ideas?

Thanks
Azhrarn

ps-> Also, how do I delete a folder content recursively without deleting the folder?
rm -Rf /bla/temp/ kills temp too.
Thx!
 
Old 04-21-2006, 11:11 AM   #2
dinolinux
Member
 
Registered: Jun 2005
Location: Oslo, Norway
Distribution: Slackware 11, Solaris 10, Solaris 9, Sourcemage 0.9.6
Posts: 322

Rep: Reputation: 31
Hi

The best way to do it is to use cron. It's a daemon which can be instructed to execute given commands at a given time. It reads the commands and time from a file called crontab. To edit crontab, simply type crontab -e as root in a shell. So to delete everything from /temp every midnight, you would type:

Code:
00 00 * * * rm -rf /temp/*
Then save the file and exit.
 
Old 04-21-2006, 02:20 PM   #3
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Rep: Reputation: 45
Quote:
ps-> Also, how do I delete a folder content recursively without deleting the folder?
rm -Rf /bla/temp/ kills temp too.
rm -r /bla/temp/*

regards,
...drsktr
 
Old 04-27-2006, 03:57 AM   #4
Azhrarn
Member
 
Registered: Aug 2005
Location: Europe
Posts: 63

Original Poster
Rep: Reputation: 15
Thanks guys!
But any ideas on how to delete a file after 24 hours of its been copied to the common folder?
Bye!
Azh
 
Old 04-27-2006, 04:07 AM   #5
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
I did a few tests and from what ive been seeing, this is how the modify, access and change times go:
If a file is copied to a new location, the three times will be set to the time of copying.
If on the other hand the file is moved to a new location:
Access stays the same it was set to when I copied the same file a few mins back, Modify stays the same as when I last actually watched the videoclip, and change is modified to the time I moved it.

You can see these three times with the stat command so that might be good grounds for writing a script (:
 
  


Reply


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
copy content of the folder ashley75 Linux - General 6 04-16-2007 10:50 AM
reading contents of a folder and moving that content vb.net mrobertson Programming 0 02-17-2006 08:14 AM
Removing a Directory from the Terminal without deleting each file or folder lennysokol Linux - General 4 05-30-2005 11:30 PM
Apache serving content after the content is removed? jrbush82 Linux - Software 6 05-05-2004 04:39 AM
deleting a shared folder aymbpc Linux - Newbie 3 09-23-2003 06:01 PM


All times are GMT -5. The time now is 02:44 AM.

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