Category Archives: Maintenance

Delete old files from huge directory with perl

If you need to delete old files from a directory but ls/find/rm/etc hang because of the number of files (especially if they’re on a slow NFS share), then you can use perl!

chdir "DIRECTORY" or die;
opendir D, ".";
$count = 0;
while ($n = readdir D) {
    $days = -M $n;
    if ($days > 3){
        #print "deleting $n $days\n";
        unlink $n or warn "Can't unlink $file: $!";
print "deleted $count files\n";

Replace DIRECTORY with your directory name, and 3 with the max age of the files to keep (here it will keep files 3 days old or less).

If you’re running this on AWS EFS then temporarily switch the filesystem throughput mode from burstable to provisioned, otherwise it will start quick but get very very slow once you’re out of burstable credits.

Oh noes! Kivy dependency installation has killed my graphics

If you are in the habit of blindly installing packages onto your personal machine while following installation instructions for some new shiny program, and that current shiny program is Kivy (1.9) and your version of xorg is a bit out of date, you may find a black screen the next time you boot.

This is due to the following kivy dependencies which have upgraded your xorg dependencies and broken xorg:


When you try and start xorg, you will get an error similar to:

No such file or directory: /usr/bin/x


To fix, upgrade xorg to quantal version:

apt-get install xserver-xorg-lts-quantal


I rebooted into failsafe graphics mode, then normal mode (both failed), then normal mode again and everything was working.

MySQL database dump & restore

Putting this here as I keep having to google it (paranoid that I’d do something wrong and mess up the db more than anything else) and keep finding crap results.

mysqldump -u [username] -p [database_name] > dump.sql
# it then prompts for the password

mysql -u [username] -p [database_name] < dump.sql
# it then prompts for the password