Script to remove oldest file in a directory

I’ve created a script in order to manage the /var/spool/cups directory. I like saving cups spool files for as long as possible, but cups will only allow one to set the maximum spool files to save. It doesn’t allow one to set a minimum % free disk space. Here is the script. It monitors the % space used in a given path and if the % free space is below the set amount the script will delete the oldest file in the directory until the free space is below the % given. Here’s the code:
#!/bin/bash
SPOOL_DIR="/var/spool/cups" #location of cups spool
MAX_USAGE="80" #maximum % disk space used 

while [[ $(df "$SPOOL_DIR" | tail -n1 | awk '{print $5}' | cut -d"%" -f1) -gt "$MAX_USAGE" ]] ; do
        ls -t $(find "$SPOOL_DIR" -maxdepth 1 -type f) | tail -n1 | xargs rm -v
done

Batch convert MKV to MP4 using ffmpeg

I had a bunch of files in mkv format that I needed to convert to mp4 format so that minidlna could serve them to my Xbox 360. Here’s how they can be converted in batch using ffmpeg.
for f in *.mkv; do 
fn="${f%.*}"
ffmpeg -i "$fn.mkv" -vcodec copy -acodec aac -ac 2 -strict experimental "$fn.mp4";
done
I used the following pages as resources: http://askubuntu.com/questions/159708/convert-mkv-to-mp4-with-ffmpeg http://www.unix.com/shell-programming-scripting/36851-separating-filename-extension.html

Transfer a block device (or a file) over the network via ssh using dd.

Today I was converting some local virtual machine storage from LVMs to .img files on remote host. One can copy block devices over the network using SSH with a command like this:
dd if=/dev/vg/logicalvolumehere bs=1500 | ssh user@remotehost dd of=/path/on/remote/host.img
… or one could pass it through gzip first to compress the data as it goes over the network.
dd if=/dev/vg/logicalvolumehere bs=1500 | gzip -c | ssh 10.3.2.3 gzip -dc \| dd of=/path/on/remote/host.img
Running the transfer through gzip, I was able to get a speed of 16.6 MB/s or about 133 megabits/sec. over a 100 megabit network.

Locked user profiles in Windows 7/Vista/2008

I’ve been experiencing this problem at work for over a year. After the system was up for an undetermined period of time, users who logged in would sometimes receive the following message.

You have been logged on with a temporary profile. You cannot access your files and files created in this profile will be deleted when you log off. To fix this, log off and try logging on later. Please see the event log for details or contact your system administrator.

This appears in the event log as event id 1502, 1515, and 1511.

I had tried to resolve the problem numerous times and was never able to find any answers better than “restart the system”. Not good enough. Then yesterday, I FINALLY found a thread which accurately identified the cause of the problem. Apparently, it’s Google Updater!

One poster on another thread solved the issue by uninstalling Google Updater, however, I didn’t want to go so far just yet. Instead, I disabled the scheduled tasks setup by Google and the Google Updater Service. I scheduled a restart on the server and, so far, I haven’t seen the locked profiles issue again.

Update: I did more testing on this and the solution is indeed to remove Google Updater. I re-enabled the “GoogleUpdateTaskMachineCore” and “GoogleUpdateTaskMachineUA” tasks, and things seem to be working fine.