LinuxQuestions.org
Help answer threads with 0 replies.
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 03-05-2006, 03:23 AM   #1
vikrambhimbar
Member
 
Registered: Aug 2005
Location: India
Posts: 33

Rep: Reputation: 15
Smile Need help for writing Script


Hi ,

I am trying to write script which will delete two days older files from /tmp directory on my server.
I am able to list down the files which are two days older but not able to del them.

Can any one help me regarding this..


Thanks.
Vikram
 
Old 03-05-2006, 04:08 AM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
If you're using find to identify the files, something like the following might do the job:
Code:
find /tmp -type f -mtime +2 -exec rm -f {} \;
Or to avoid recursing the directories
Code:
find /tmp -type f -maxdepth 1 -mtime +2 -exec rm -f {} \;
Unless you're completely certain that no false positives can occur I'd suggest a trial run first:
Code:
find /tmp -type f -mtime +2 -exec ls -l {} \; > ~/trial-run.log
Or to avoid recursing the directories
Code:
find /tmp -type f -maxdepth 1 -mtime +2 -exec ls -l {} \; > ~/trial-run.log
 
Old 03-05-2006, 04:28 AM   #3
vikrambhimbar
Member
 
Registered: Aug 2005
Location: India
Posts: 33

Original Poster
Rep: Reputation: 15
Thanks

Hi

Thanks for your help.
This thing works .


Thanks
Vikram
 
  


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
Help writing a script mral Linux - Newbie 4 12-29-2005 12:34 AM
help with writing a script jedimastermopar Linux - General 10 05-02-2005 01:34 PM
help writing script willinusf Programming 7 07-20-2004 11:37 AM
Writing a Script Nyc0n Linux - General 2 05-27-2002 07:21 PM
writing a Script spanky5125 Linux - Security 5 01-08-2002 09:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration