Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Need help writing UNIX script
Name: Tam Date: August 8, 2001 at 14:50:30 Pacific
Comment:
I'm trying to write a unix script that will delete files in a specific directory after they are 30 days old. I know how to do this conceptually but this is my first time. Here is what I'm trying to do:
Get system date Get file date If (SystemDate-FileDate>30) Delete file
please email if possible. sometimes i have problems getting on the web. thanks!!!
Name: stefan caunter Date: August 8, 2001 at 20:04:26 Pacific
Reply:
you need to find based on age, and then have the files which are found deleted:
find /directory -atime 30 -exec rm {} \;
this will delete files not accessed in the last 30 days. if you want confirmation before deletion use
-ok rm {} \;
after the find path option
if you want it to be a script just have $1 as the path, and enter it as the first arg to the script name on the command line. there are a number of good options to find which can be useful for this kind of thing.
Summary: please help: how can i write a script Example 1: [min@alpha min]$ ./mt Enter an integer number: 3 You entered 3 The sum of all the integer from 0 to 3 is 6 The integer 3 that you entered is odd Ex...
Summary: i need to write some scripts: 1- that get dir from arg and save to file. 2 - get 2 dirs from args, compare, report if equal. 3- Compare logged-in users to users list in file -> report “problems” ...
Summary: The answer to a post about 4 below this has the basics of what you want to do. See: http://www.computing.net/unix/wwwboard/forum/2372.html (Need Help writing UNix script) Note the -atime parameter, ...