Clean Older packages


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Clean Older packages
# 1  
Old 04-05-2012
Clean Older packages

Hi All,

I need a script that automates the following process -

I do a " ls -ltr |awk ... |sort " to get a list of packages within a directory, the packages have date/time stamp on them and they get sorted out, I want to delete the packages which are of older timestamp and leaving out the last 2 packages from deletion.


Timestamp is of this pattern - <appname>-20120330-143912-456557f3f5b34a8091dcecd69ec123dd

ls -ltr |awk ... |sort

Appname1-20120330-143912-756557f3f5b34a8091dcecd69ec12423
Appname1-20120402-173057-e30fc8463a1d444185983ccb6d319c33
Appname1-20120404-182519-c32abb08f0bb4ae0bb887818d5c14022
Appname2-20120402-173057-e30fc8463a1d444185983ccb6d319c33
Appname2-20120404-182519-c32abb08f0bb4ae0bb887818d5c14022
Appname3-20120404-182519-c32abb08f0bb4ae0bb887818d5c14022

In the above case the script should delete -

Appname1-20120330-143912-756557f3f5b34a8091dcecd69ec12423
Appname1-20120402-173057-e30fc8463a1d444185983ccb6d319c33

leaving out the last 2 packages intact and should not delete.

Thanks,
Jack.
# 2  
Old 04-05-2012
how do you define old timestamp ? 1 day older ?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Clean up Scripts

Hi i have a perl script that i use to clean up empty folders on our server. I need to make a amendment to this to exclude certain folders. Folders are invisible to end users but must not be cleaned up by this script. folders i need protecting have unique names .Highres .HighresF .Lowres... (0 Replies)
Discussion started by: treds
0 Replies

2. Slackware

Find Slackware Packages - packages.acl.org.ua

Hi! Let me introduce a project for find and download Slackware packages and browse Slackware repositories. The site provides following features: * Large, daily updated database with RPM, DEB, TGZ, TXZ packages for well-known repositories of the Slackware, Fedora, CentOS, RHEL, Debian,... (2 Replies)
Discussion started by: lystor
2 Replies

3. AIX

How to clean PV id?

When I run command: >chdev -l hdisk1 -a pv=clear It shows Method error (/etc/methods/chgdisk): 0514-062 Cannot perform the requested function because the specified device is busy. run: #>fuser -kxuc /dev/raw1 /dev/raw1: How to clean PV id? (4 Replies)
Discussion started by: rainbow_bean
4 Replies

4. UNIX for Dummies Questions & Answers

Help me clean this up

UNIX amature/novice. I've written a script (it works) that needs to be cleaned up. I'm searching for a way to perform a "go to , perform this then return" section of code. The books I have and searches i"ve done so far do not show me how to do this. I've pasted in the current code below. I've... (1 Reply)
Discussion started by: scanner248
1 Replies

5. Shell Programming and Scripting

clean /etc/hosts

hi all, i need to write a script. it should be able to clean the /etc/hosts file like this: first field is the ip (what else ;)) second field is the fqdn (full qualified domain name) third field is the hostname the fourth to n'th field is the rest. i hope you understand what is needed?... (5 Replies)
Discussion started by: DukeNuke2
5 Replies

6. UNIX for Advanced & Expert Users

Clean File

BeginDate 07/01/06 End: 07/31/06 Cust: A02991 - Burnham 0002000 5,829,773 145.3 0009701 4,043,850 267.3 2005000 286,785.13 100.0 BeginDate 07/01/06 End: 07/31/06 Cust: A01239 - East Track PSE Index A 0009902 317,356.82 890.2 0020021 ... (5 Replies)
Discussion started by: kris01752
5 Replies

7. Shell Programming and Scripting

clean up script

I have a script which would monitor a given directory and delete any files which are older than 10 days. I was going to set the 10 crob jobs to perform this operation for 10 different directories (some are actually sub-directories), but my boss doesn't like that idea, so I need to do that in one... (1 Reply)
Discussion started by: mpang_
1 Replies

8. UNIX for Advanced & Expert Users

Clean an LV out of the ODM

I recently had a disk crash and was not able to clean the dump lv off the disk. Now trying to create new lvdump I am running into errors. My question is how do I remove the old lv out of the ODM? I have tried going through smit and also just rmlv and it cannot find the lv. Yet when I run lslv on... (0 Replies)
Discussion started by: Wamland
0 Replies

9. AIX

Directory clean up

I want to write a script in ksh that will delete file that are more than 2 weeks old. (4 Replies)
Discussion started by: jango
4 Replies
Login or Register to Ask a Question