Periodical Deletion of files and folders


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Periodical Deletion of files and folders
# 1  
Old 01-10-2012
Periodical Deletion of files and folders

Hi All,

how can Periodical Delete files and folders using shell script.
I.e after 1 min i want to delete files and folderns from my home directory.

Thanks,
Arun
# 2  
Old 01-10-2012
Code:
while [ 1 ]
do
  rm -rf /home/username/*
  sleep 60

The above code will delete the contents of the /home/username/* and wait for 1 minute and again it will delete the contents.....
# 3  
Old 01-10-2012
actual requirement is.
if i put a file in home directory it will delete a file after 1 min.
but in above code first it will delete and wait for 1 min.
# 4  
Old 01-10-2012
rm

Hi,

Try this,

Code:
while [ 1 ]
do
`find /home/username -mmin +1 | xargs rm`;
done

Cheers,
RangaSmilie
# 5  
Old 01-10-2012
it gives error like ...
usage:rm [-fiRr] files....
what i can do??
# 6  
Old 01-10-2012
find

Hi,

what your platform unix or linux?

For a try, just add -rf at the end of the find cmd.

Code:
`find /home/username -mmin +1 | xargs rm -rf`;

Cheers,
RangaSmilie
# 7  
Old 01-10-2012
Quote:
Originally Posted by rangarasan
Hi,

Try this,

Code:
while [ 1 ]
do
`find /home/username -mmin +1 | xargs rm`;
done

Cheers,
RangaSmilie
It will not wait for 1 minute.

And it executes the find command continously (infinite time) and keep on searching for 1 minutes older file.
This User Gave Thanks to itkamaraj For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to copy files/folders and show the files/folders?

Hi, So i know we use cp -r as a basic to copy folders/files. I would like this BUT i would like to show the output of the files being copied. With the amazing knowledge i have i have gone as far as this: 1) find source/* -exec cp -r {} target/ \; 2) for ObjectToBeCopied in `find... (6 Replies)
Discussion started by: Imre
6 Replies

2. Debian

Problem with files/dirs deletion

Hi, The other day i installed a PHP based CMS (modx) on my shell account and noticed that i couldn't delete any of files/dirs it created after. Also, i noticed that all that stuff is owned by username-www instead of username. I tried chown, chmod and using a PHP script to do the same wti... (4 Replies)
Discussion started by: pentago
4 Replies

3. UNIX for Dummies Questions & Answers

Searching for folders/parent folders not files.

Hello again, A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x. I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
Discussion started by: Aussiemick
2 Replies

4. Shell Programming and Scripting

Files Deletion After 20 Minutes

Hi, everyone. Could you help me with deletion of files, which are 20 minutes old. I found out how to make deletion for files in that way : find <dir> -mtime n -exec rm -rf "{}" Could you offer your suggestions. Many thanks in advance. (5 Replies)
Discussion started by: KReoN
5 Replies

5. Shell Programming and Scripting

Fake deletion of files

Hi, This is possibly an odd request to do with permissions as I seem to have tied myself up with these! I have the following directory (see below) that contains files that the 'usergrp' user needs to be able to 'delete' files from. drwxr-s--- 2 usergrp usergrp 512 16 Feb 14:37... (2 Replies)
Discussion started by: Peejay
2 Replies

6. Shell Programming and Scripting

Multiple Files deletion in perl

Hello Friends, I want to delete all the "*.trg" files in a directory but i don't want to do it by system("rm -r *.trg"); Can i do it thru unlink or by any other mean Thanks, Pulkit (1 Reply)
Discussion started by: pulkit
1 Replies

7. Shell Programming and Scripting

Script for automatic deletion of old files

Hi, I have a folder with limited space. I do not have provisions to increase the space for this folder. So i have to delete files which are more than 1 month old automatically. But, i need to maintain the files created by 4 users and delete all the other files automatically which is more than 1... (4 Replies)
Discussion started by: vivek_scv
4 Replies

8. Shell Programming and Scripting

Periodical checking

I want to check periodically, every "period" seconds given by the user ,if a user logged in or logged out of the system.If he did print a message with his name and his time of logging in or out.for tcsh Thank you for your time. (3 Replies)
Discussion started by: aekaramg20
3 Replies

9. UNIX for Dummies Questions & Answers

Deletion of log files.

We have log files dating back to 2004. I need to write an interative script that will request the user for how many months he needs to keep the log files and remove all the remaing log files after that month. Supposing we are now in June 2006 , if teh user request to keep log file for the last 3... (1 Reply)
Discussion started by: Geeta
1 Replies

10. Shell Programming and Scripting

Regarding deletion of old files

Hi, I have a list of directories which contain old files that are to be deleted. I put the list of all directories in a txt file and it is being read by a script Iam searching for the files older than 60 days using mtime and then deleting it But all the files are getting deleted... (3 Replies)
Discussion started by: Chidvilas
3 Replies
Login or Register to Ask a Question