You are not logged in.

#1 2005-11-29 00:16:16

xterminus
Member
From: Tacoma, WA, USA, Earth, Sol, M
Registered: 2005-10-30
Posts: 93

keeping pacman archive tidy

I've only been running arch for about a month now, and was wondering where all my hard disk space on my root drive was disappearing to.   After a few minutes of poking around, I found /var/cache/pacman and noticed it was already over a gigabyte in size.

The following is a very small script I added to my cron schedule to keep it trimmed and tidy.  Hopefully someone else will find it useful.

#!/bin/sh
# $Id: cleancache 143 2005-11-28 07:20:38Z cmauch $
#
# Author: Charles Mauch (charles@mauch.name)
# Description: Clean up Arch Pacman Cache
# Created: Sun 27 Nov 2005 04:53:48 AM PST
# Legal: (c) Charles Mauch, released under the terms of the GPLv2

find /var/cache/pacman/pkg/ -atime +14 -exec rm {} ;
find /var/cache/pacman/src/ -atime +14 -exec rm {} ;

As you can see, it's just two lines.  -atime tells find to look for files that haven't been touched in two weeks, and then it nukes them.  I run it in my nightly cronjob.  I suggest dropping this file in /etc/cron.daily.  Then you dont' have to bother logging in as root and modifying the root user crontab.

Offline

#2 2005-11-29 00:22:23

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: keeping pacman archive tidy

zomg! adding now

Offline

#3 2005-11-29 00:40:01

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: keeping pacman archive tidy

Good idea, but some people like having those cached packages around to revert if necessary, so I imagine this will be a person-by-person boon/unnecessity, as most things.

Also, were you aware of pacman -Sc?

# du -h /var/cache/pacman
2.9G    /var/cache/pacman/pkg
127M    /var/cache/pacman/src
3.0G    /var/cache/pacman

# pacman -Sc
removing old packages from cache... done.

# du -h /var/cache/pacman
1.1G    /var/cache/pacman/pkg
127M    /var/cache/pacman/src
1.3G    /var/cache/pacman

# 

Handy to get rid of only the old packages - ones you've upgraded or removed since you last installed them.

Offline

#4 2005-11-29 05:06:02

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: keeping pacman archive tidy

Cerebral wrote:

Good idea, but some people like having those cached packages around to revert if necessary, so I imagine this will be a person-by-person boon/unnecessity, as most things.

Yes, but the 14 day delay is what makes this good - if you were going to roll something back, it'd be much quicker than 14 days

Offline

#5 2005-11-29 05:58:23

kakabaratruskia
Member
From: Santiago, Chile
Registered: 2003-08-24
Posts: 596

Re: keeping pacman archive tidy

phrakture wrote:
Cerebral wrote:

Good idea, but some people like having those cached packages around to revert if necessary, so I imagine this will be a person-by-person boon/unnecessity, as most things.

Yes, but the 14 day delay is what makes this good - if you were going to roll something back, it'd be much quicker than 14 days

I think pacman -Sc cleans old packages, and pacman -Scc cleans all packages.


And where were all the sportsmen who always pulled you though?
They're all resting down in Cornwall
writing up their memoirs for a paper-back edition
of the Boy Scout Manual.

Offline

#6 2005-11-29 06:06:49

stonecrest
Member
From: Boulder
Registered: 2005-01-22
Posts: 1,190

Re: keeping pacman archive tidy

phrakture wrote:
Cerebral wrote:

Good idea, but some people like having those cached packages around to revert if necessary, so I imagine this will be a person-by-person boon/unnecessity, as most things.

Yes, but the 14 day delay is what makes this good - if you were going to roll something back, it'd be much quicker than 14 days

I don't find this to be true. A "common" scenario is that I will do a kernel upgrade, for example, and it will break ndiswrapper or something like that. If my previous version of ndiswrapper was installed for longer than 14 days, then I would have no way of reverting. This doesn't give you a 14-day window to revert, it gives you 14 days on your currently installed package.

It's an interesting idea but I will continue just nuking the large packages (openoffice, xorg, etc) by hand smile


I am a gated community.

Offline

#7 2005-11-29 18:19:51

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: keeping pacman archive tidy

kakabaratruskia wrote:
phrakture wrote:

Yes, but the 14 day delay is what makes this good - if you were going to roll something back, it'd be much quicker than 14 days

I think pacman -Sc cleans old packages, and pacman -Scc cleans all packages.

-Sc cleans all but the latest version of each package from the cache.
-Scc cleans everything from the cache.
This script cleans everything older than 14 days from the cache.

It's just another way to do it.  Each one has it's use.  For me, this one works the best - I mean think about it this way:
With all these initscripts updates going on, your options are to run "pacman -Sc" and you're left with the current installed version sitting in your cache (no rollback), run "pacman -Scc" and you're left with nothing, or run this script and you're left with the packages from the last 14 days, giving you ample packages to rollback to if one of the initscript changes happens to break.

Offline

#8 2005-11-29 18:39:23

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: keeping pacman archive tidy

Tsk, tsk, a small problem with that solution could be that it's based on atime and some people tend to mount their filesystems with 'noatime' flag, to somewhat enhance performance.

Just a lil' digression.

Offline

Board footer

Powered by FluxBB