duncanlock.net

Switch on logging for cron

Edit the /etc/rsyslog.conf or /etc/rsyslog.d/50-default.conf (on Ubuntu) file and make sure you have the following line un-commented (or add it if it’s missing):

cron.*                         /var/log/cron.log

Then restart rsyslog and cron:

$ sudo service rsyslog restart
$ sudo service cron restart

Cron jobs will now log to /var/log/cron.log. What cron actually outputs to this log looks something like this:

Jan 31 07:30:01 duncan-desktop CRON[3971464]: (duncan) CMD (/home/duncan/bin/backup-chrome-window-placement.sh 2>&1 # JOB_ID 3)
Jan 31 07:31:04 duncan-desktop anacron[3971646]: Anacron 2.3 started on 2021-01-31
Jan 31 07:31:04 duncan-desktop anacron[3971646]: Will run job `cron.daily' in 5 min.
Jan 31 07:31:04 duncan-desktop anacron[3971646]: Jobs will be executed sequentially
Jan 31 07 …
Continue reading “Debugging cron jobs”

What would a unixy music collection actually look like, if we could start from scratch?

Everything Is A File

  • Everything is a file - including metadata
  • Separate music data from meta data
  • Separate static metadata from dynamic ‘play’ metadata - playcounts, last played time, etc…​
  • Each ‘thing’ in a collection: an album, an artist, a track - becomes a folder

Hierarchical Folder Structure

Music/
-- library-meta.yml
-- Collections/
---- global-collections-meta.yml
---- By Artist/
------ by-artist-collection-meta.yml
------ ABBA/
-------- artist-meta.yml
-------- artist-photo.jpg
-------- Waterloo/
---------- album-meta.yml
---------- cover.jpg
---------- back.jpg
---------- booklet.pdf
---------- playlist-mp3.m3u
---------- playlist-flac.m3u
---------- 01 - Waterloo/
---------- 02 - Sitting in the Palmtree/
------------ track-meta-static.yml
------------ track-meta-play.yml
------------ Sitting in the Palmtree.flac
------------ Sitting in the Palmtree.mp3
---------- 03 - ....
...
---- By Decade/
------ 70s/
-------- ABBA/
---------- Waterloo/ (symlink)
  • could have a FUSE file system to make this look like a regular music collection, or vice versa
  • possible multiple versions of anything at …
Continue reading “What would a UNIX Music collection look like?”

$ sudo su -

$ mkfs.btrfs -f /dev/sdb
$ mkfs.btrfs -f /dev/sdc

$ btrfs fi show

Should give you output something like this:

Cannot analyze code. No Pygments lexer found for “txt”.

.. code-block:: txt

        Label: none  uuid: bfee4bb4-3886-406f-94df-cb2dcf42f044
                Total devices 1 FS bytes used 112.00KiB
                devid    1 size 5.00GiB used 548.00MiB path /dev/sdc

        Label: none  uuid: a0192bd3-a8f7-477b-9bae-fea9a48aa1ab
                Total devices 1 FS bytes used 2.24GiB
                devid    1 size 5.00GiB used 3.04GiB path /dev/sdb

        Btrfs v3.12

$ mkdir /mnt/butter

$ mount /dev/sdb /mnt/butter $ btrfs device add -f /dev/sdc /mnt/butter

$ btrfs fi show

Label: none  uuid: a0192bd3-a8f7-477b-9bae-fea9a48aa1ab
        Total devices 2 FS bytes used 2.24GiB
        devid    1 size 5.00GiB used 3.04GiB path /dev/sdb
        devid    2 size 5.00GiB used 0.00 path /dev/sdc

Btrfs v3.12

$ btrfs fi …
Continue reading “Setting up a Raid1 Btrfs Home partition”

We use CentOS VMs at work to emulate our production environment - and it took me a while to figure out how to get the VirtualBox Guest Additions to build reliably on CentOS 6.4/5. This is what I’ve currently settled on as a reliable method.

First, make sure that you’ve got the kernel headers and tools installed that you need to build stuff:

$ sudo yum update -y
$ sudo yum install gcc kernel-devel kernel-headers dkms make bzip2 perl

Make sure that you’ve only got the current set of kernel headers installed - the one for the kernel you’re actually running. Having more than one set installed prevents this working properly. Running this should show you one version of each kernel package:

$ rpm -qa | grep kernel | sort

It should look something like this:

dracut-kernel-004-336.el6_5.2.noarch …
Continue reading “Reliably Building VirtualBox Guest Additions on CentOS 6.x”

To create image thumbnails from a PDF document, run this in a terminal window:

$ convert -thumbnail x300 -background white -alpha remove input_file.pdf[0] output_thumbnail.png

The parameters to convert do the following things:

ParameterEffect
-thumbnailSimilar to -resize, but optimized for speed and strips metadata.
x300Make the thumbnail 300px tall, and whatever width maintains the aspect ratio.
-background whiteSets the thumbnail background to white.
-alpha removeRemoves the alpha channel from the thumbnail output.
input_file.pdfThe PDF file to use as input.
[0]The page number of the input file to use for the thumbnail.
output_thumbnail.pngThe output thumbnail file to create.

If you want larger thumbnails, just change the x300 parameter to match. If you want to output .jpg’s (or anything else, like .gif), just change the file …

Continue reading “How to create thumbnails for PDFs with ImageMagick on Linux”

https://github.com/kragen/xcompose

Continue reading “How to add new Compose Key combinations on Linux”

I’m going to build on Jamie Zawinski’s excellent advice about backups, which you should read first. This is basically that, but with some extra bits. If this seems too complex, then just do what he says.

The plan is to use Backupninja to backup everything to an external USB drive – and also to Amazon S3 or Dropbox, depending on what it is. Backupninja provides a centralized way to configure and schedule many different backup utilities, just by dropping a few simple configuration files into /etc/backup.d/.

I have a multiple hard disk setup for my desktop Linux box - my /home folders live on one disk and / lives on another one. I don’t want to backup everything from the system disk - I can re-install it in 10 mins, and I don’t really want to complicate this …

Continue reading “Comprehensive Linux Backups with etckeeper & backupninja”

I recently needed to convert some FLAC music files from the increasingly common 48 bit encoding, down to 16 bit at 44100 kHz, so that they’ll play on my Sonos. Here’s how to do it:

If you don’t already have sox installed, do this to install it:

$ sudo apt-get install sox

Then run this to do the conversion, in the folder with music in:

$ mkdir resampled
$ for flac in *.flac; do sox -S "${flac}" -r 44100 -b 16 ./resampled/"${flac}"; done

And that’s it - it will convert all the .flac files in that folder to 16 bit at 44100 kHz and put the result into the ./resampled subfolder, preserving the metadata.

Continue reading “How to convert FLAC files from 24/48 bit to 16 bit on Ubuntu Linux”

Thunar's icon

Thunar - XFCE & XUbuntu’s small but perfectly formed file manager - has a simple mechanism that allows you to easily add new commands to the right click menu of files and folders. These are called Custom Actions and are easy to create…​ here’s how to do it.

Click the Edit menu, then click ‘Configure custom actions…​‘. This will take you to the Custom Actions Manager, where you can create, edit or delete your custom actions.

You can enter anything into the command box, including complex bash scripts, names of scripts or executables on the PATH, or the full path and filename of the command you want to run.

thunar custom actions edit 1

On the ‘Appearance Conditions‘ tab, you tell Thunar when you want your item to appear in the right click menu:

thunar custom actions edit 3
Figure 1. Now, when I right click on a text file, I …
Continue reading “Useful Thunar Custom Actions”

http://unix.stackexchange.com/questions/35255/command-line-audio-piping-for-simultaneous-playback-and-recording http://linux.die.net/man/1/sox http://sox.sourceforge.net/

$ sudo apt-get install sox mbuffer tcpdump
$ sudp apt-add-repository ppa:nadaeck/spectrum3d
$ sudo apt-get update && apt-get install spectrum3d
$ sudo tcpdump -i eth0 -n -w- | mbuffer -P 10 | play --buffer 1500 -r 8000 -b 8 -c 1 -e signed-integer -t raw - band 2k speed 0.1 reverb
Continue reading “Data as Art: Visualizing your network traffic in realtime”