Here’s a simple solution to run multiple instances of Firefox, each with own user profile (and thus cookies, extensions and themes), all running as separate processes. Useful for troubleshooting and to keep one misbehaving site from crashing all your firefox windows (I’m guilty of running way too many at once).
Got thousands of tar archives being transferred from various machines to one repository. Found that some of the archives are bad, either because the network transfer didn’t complete or the archive process was interrupted on the machine that created the archive (due to insufficient disk space, etc). Whatever the cause, needed a method to verify the archive integrity.
Tar provides options for verify the archive integrity by comparing it with the file system. In this case, I needed the ability to verify the archive without access to the original file system.
The BASH one liner below will find all archives below current directory, loop through each one attempting to list its contents, discard the archive content list, capture and log the tar command’s exit status along with archive name and redirect both to a log. Exit status of 0 means the archive is good, 2 means it’s bad (haven’t seen a 1). Redirecting output to /dev/null while capturing exit status turned out trickier than I thought, but this seems to work well:
1 | for f in $(find . -name "*tar.bz2"); do tar tfj $f &> /dev/null; err="$?"; echo $err $f >> tar-check.list; done |
The split command is one gem of a Giant Dork tool, but it expects to be given the number of lines to split a file along. It’s easy enough to fire up a calculator to do this, but sometimes a programmatic method is desirable. Here’s a bashism that’ll do it:
1 | split -l $(echo $(( $(cat sourcefile | wc -l) / 3))) sourcefile sourcefile. |
When syncing files over a trusted network, where speed matters more than someone’s ability to see contents of the transfer, might want to run rsync as a daemon instead of using remote shell as the transport.
In my tests, running rsync as a daemon produces file transfers almost twice as fast as when rsyncing over SSH.
A project I’m working required a comma delimited file containing date ranges, in one week increments, from July 1987 to the present. That’s 1166 week ranges. What sounds like a potentially time consuming ordeal, takes about 10 sec to produce with the following shell one liner:
for n in $(seq 0 1166); \ do echo -e \ $(date +%m/%d/%Y --date="1987-07-01 +$n week")","\ $(date +%m/%d/%Y --date="1987-07-01 +$n week +6 day") \ >> date.ranges; done
Most of the stuff I do is via the shell, but once in a while need to attach to an existing X session on my work desktop. My requirements are that the method:
- Uses SSH for authentication
- Tunnels VNC traffic over SSH for security and so no additional ports need to be opened
x11vnc is what I’ve been using. Here’s a little shell script I wrote that will take user@hostname as a variable, enumerate an existing GDM session on the remote computer, create an SSH tunnel and attach to it via VNC. It uses aggressive compression, which looks a bit ugly but still works over a low bandwidth connection. The auth file enumeration bit works with Gnome, but could probably be adapted for use with other window managers.
1 2 3 4 5 | sudo -s if [ -f /tmp/nmap.* ]; then rm /tmp/nmap.*; fi nmap -sP -PA 192.168.0.0/24 >> /tmp/nmap.sweep for h in $(grep Host /tmp/nmap.sweep | awk '{print$2}'); do $c -PN -A $h >> /tmp/nmap.scan; done less /tmp/nmap.scan |
This is a (long overdue) follow up on my ancient post on how to setup a Nokia E62 as a bluetooth modem on a Windows laptop. It’s been a couple of years now since I’ve purged the Winblows partition from my Dell Inspiron 1501 and it’s been happily running Ubuntu using the E62 to get to the Internets. Just got a Dell Mini 10 for work, so might as well post the steps while they’re still fresh in memory (my RAM gets regularly purged, as it turns out).
Partitioned a 4.2TB volume with fdisk, created a file system and all I got for was a lousy 2TB. WTF? fdisk man page explains:
fdisk doesn’t understand GUID Partition Table (GPT) and it is not designed for large partitions. In particular case use more advanced GNU parted(8).
Ok, parted it is then..
Setup a new backup server and getting the following error from Cron in /etc/cron.daily/logrotate:
error: error running shared postrotate script for /var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log run-parts: /etc/cron.daily/logrotate exited with return code 1