[lang]

Present Perfect

Personal
Projects
Packages
Patches
Presents
Linux

Picture Gallery
Present Perfect

N800 wizards

Filed under: Hacking — Thomas @ 5:35 pm

2007-6-15
5:35 pm

Please enlighten me – what is this process called “enprocess” that runs on my N800 as soon as it boots, takes pretty much all of my CPU most of the time, and seems to not mind to be killed completely as far as I can tell ?

What is it, what is it doing taking so much CPU and wearing my poor battery out, and where are the docs on this ? No man pages makes it hard to figure out…

UPDATE: it was indeed a process related to email.  I fixed it permanently by moving my mail directory ouf of the way, and restarting the mail application and reconfiguring my email account.  Now it seems to be a lot less CPU hungry.  Thanks everyone who commented.

deleting backups

Filed under: General — Thomas @ 1:58 pm

2007-6-11
1:58 pm

backups are good.

Over the years I’ve come to realize this simple mantra, to the point of thinking, every time I put in place a new service – “how do we back this up ?”

Usually the answer is relatively simple. You svndump an svn repository then tar/bzip2 it. You dump a trac setup and tar/bzip2 it along with the config files. You rsync over maildirs (not entirely correct but good enough). You add this as a daily cron job. And so on.

This isn’t perfect, though. Sooner or later you will have to deal with the swaths of disk space your backups are wasting. And really, do you still need the svn dump from two years ago on Monday if you also have Sunday and Tuesday ?

So really, what you want is something more like “only keep the daily backups for three months, and after that only keep a weekly backup, or one every x days”.

I searched for ages among various find-like tools to make this possible from a shell script, and never found anything useful. Two weeks ago I decided I’d just write it in python, and it turns out it’s a lot simpler than I was fearing it would be:


#!/usr/bin/python

import glob
import stat
import os
import time

files = glob.glob('*')

for file in files:
keep = False

s = os.stat(file)
mtime = s[8]

# keep if it is from a sunday
anyGivenSunday = time.mktime((2007, 5, 6, 0, 0, 0, 0, 0, 0))
secondsPerDay = 24 * 60 * 60
if (mtime - anyGivenSunday) % (7 * secondsPerDay) < secondsPerDay:
keep = True

# keep if it is younger than 3 months
now = time.time()
if now - mtime < 90 * secondsPerDay:
keep = True
print file, mtime, keep

This script prints out one line per file from the current directory, with True in it if the file should be kept.
So typically I run this as

keep-sundays | grep False | cut -d' ' -f 1

to see the list, and then add “xargs rm” if the list makes sense.

Next step would probably be to refine this a little, add some arguments, and put in a cron job, but for now it solves the problem of weeding out my backups and free some disk space on our servers after 3 years of backups.

kill kill kill

Filed under: General — Thomas @ 2:07 pm

2007-6-8
2:07 pm

Every two times you open the box, Schrödinger kills a kitten.

Congratulations to Dave and Christian to getting a bitstream-stable release out !

marketeering

Filed under: General — Thomas @ 6:17 pm

2007-6-4
6:17 pm

Spotted on the way back from the airport: Mandarine Duck, the new fragrance for men.

God, do I *wish* I were a fly on the wall in that brainstorming meeting.

What kind of guy would want to smell like something named after a dish in a Chinese Restaurant ? Which woman would ever go “God, you smell of ducks and it turns me on” ? (Hint: ducks typically smell like duck poo or pond scum).

« Previous Page
picture