- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need a clean up script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2012 10:11 PM
04-04-2012 10:11 PM
Hi!
I have a dirctory which has a list of packages (both old and ones which are currently running)-
dir1> ls -ltr
app1-oldpackage
app2-oldpackage
app3-oldpackage
app1-current-package
app2-current-package
app3-current-package
I currently run ps -ef |grep <package-name> to find out which are currently running and then rm -fr old-packages to create space.
Is there a better way to create a script and cleanup using that.
Thanks,
Allan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2012 10:28 PM
04-04-2012 10:28 PM
Re: Need a clean up script
If your packages don't contain a file with the current running PID there isn't much else you can do.
Or if you aren't using them, move them into an "OLD" directory, until you know for sure you want to remove them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2012 10:00 AM
04-05-2012 10:00 AM
Re: Need a clean up script
Hi Dennis,
One thing I missed mentioning here,
I do an ls -ltr |awk ... |sort to get a list of packages with that dir, the packages have date/time stamp on them and they get sorted out, I want to delete the packages which are of older timestamp.
Timestamp is of this pattern - <appname>-20120330-143912-456557f3f5b34a8091dcecd69ec123dd
I want to delete any packages which are older than the new package.
ls -ltr |awk ... |sort
Appname1-20120330-143912-756557f3f5b34a8091dcecd69ec12423
Appname1-20120402-173057-e30fc8463a1d444185983ccb6d319c33
Appname1-20120404-182519-c32abb08f0bb4ae0bb887818d5c14022
Appname2-20120402-173057-e30fc8463a1d444185983ccb6d319c33
Appname2-20120404-182519-c32abb08f0bb4ae0bb887818d5c14022
Thanks,
Allan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2012 01:19 PM
04-05-2012 01:19 PM
Re: Need a clean up script
I am thinking of using -atime with find to have this taken care of.
Do agree that a longer term solution is to push the older packages to differnt fs.
Thanks,
Allan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2012 09:58 PM - edited 04-05-2012 09:59 PM
04-05-2012 09:58 PM - edited 04-05-2012 09:59 PM
Solution>I want to delete any packages which are older than the new package.
Assuming there is a "-" between the app and the timestamp, this should do it:
ls -l | awk '
BEGIN { prev = ""; app = "" }
{
# get appname
n = split($9, apps, "-")
if (n == 0) next # total line
if (n < 2) {
print "problem getting appname for", $9
next
}
appname = apps[1]
if (appname == app) {
print prev # older
prev = $9 # save
next
}
# ignore prev, since last/only
app = appname
prev = $9
} '
This prints all but the last of any application group.