2013-01-02

alexpgp: (Visa)
2013-01-02 06:50 pm

"Cron!" swore Conan...

Yes, it says "Crom!" in all the Robert E. Howard books, but in my ceaseless quest for a good dose of cognitive dissonance, I like to think the Cimmerian was secretly a Unix user (cron being the name of the time-based job scheduler in Unix-like operating systems). But I digress...

So I get this idea last year (not so long ago, really) to create a daily job to back up the invoice database that's on my Raspberry Pi. This would appear to be a cinch, as there are a pile of places on the Web that'll tell you how to do this. The place I chose explained things straightforwardly, suggesting that the output of the mysqldump command could be piped to gzip as follows:
... | gzip > /media/usb/database_`date +%m-%d-%Y`.sql.gz
It worked like a charm from the command line, and after editing the line slightly to render the date in YYYY-MM-DD format, I created a "cron job" set to run every morning at 12:11 am.

Unfortunately, cron treats percent signs (%) in a very special way—the first one signals the start of stdin, and the rest get converted to newlines—so my carefully crafted job description turned to dross rather quickly. Attempting to "escape" this treatment of the percent sign with a backslash (`date +\%m-\%d-\%Y`) keeps the percent sign, but the backslashes as well.

Fortunately, I found a way to specify the date format that I wanted without using percent signs (`date --rfc-3339='date'`) and everything works.

Good to find this kind of stuff out now, instead of after a need arises to restore the database.
alexpgp: (Default)
2013-01-02 09:41 pm

USB wall wart...

A number of products, such as the Applie iPad, come with a device that plugs into a standard 120-Vac outlet and outputs 5-Vdc through a USB connector. During my several visits to Fry's here locally during December, there was a bin of these units on sale for about $5 each. A need for an extra unit arose this past weekend and after seeing a price of $13 for one at the local supermarket, I decided to return to Fry's.

I managed to do that today, and found that the bin was gone and the least expensive charger available was a NuGiant charger for about $10. What is unusual about the unit is that it doesn't actually plug into an outlet so much as slip over a three-prong plug that, in turn, plugs into an outlet. It's actually a pretty clever design that provides functionality without impacting the availability of outlet receptacles.

Whether it will stand up to a lot of day-to-day handling is another issue, but one I don't expect to have to worry about all that much once I get it installed where it's needed.

Cheers...