Locking Cron Jobs

Some cron jobs have the potential for running longer than their allotted interval, and you don't want to end up running multiple copies, especially where that creates additional load meaning the jobs take even longer to complete. That's a sure-fire recipe for disaster.

Historically I've always coded this into a shell script to use "ps" and exit if a copy of the job is already running. That works, but it's a pain to reimplement it every time. Somehow I missed that there is a tool built exactly for this specific function, named flock.

As a simple example:

flock -xn /tmp/lockfile -c /path/to/script

Hat tip to https://bencane.com/2015/09/22/preventing-duplicate-cron-job-executions/.

Random Greetings in Home Assistant

There's a server in my office and it has an audio card in it, so I figured why not have Home Assistant speak things to me. I started simple with just a basic greeting when the lights came on, and a goodbye when the lights went off. But then I decided to up the ante and have Home Assistant pick a greeting randomly from a list. Spice things up a bit.

Deploying Pi-hole

During the process of managing my Home Assistant server, I discovered a neat little tool named Pi-hole and decided to give it a whirl. It's a DNS server which uses blacklists to block ads and various flavors of crapware. So far it's been working really well, without any negative side effects that I've noticed.

Among the things I've discovered by browsing the reports:

  1. Google Chrome sends out a handful of DNS requests for random domains every time it starts up, to try and detect DNS hijacking
  2. My son's phone goes bonkers at midnight and requests a few thousand Google ads. I'm thinking maybe there's a bad app installed on there. That alone counts for 80% of the blocked requests.
  3. There are a lot of apps that phone home to the mother ship. I knew it happened, but I'm blown away by the actual scale of it. It's ridiculous. Not just the advertising, but the privacy leaks.
  4. Just from DNS, there is a lot you can infer about site a person is visiting. TLS won't help you there.

My next step is deciding whether to deploy this via VPN on my phone. I like the idea, but not sure if I want the hassle of it.

Asterisk IAX User Matching

I spend another couple hours tonight banging my head on the keyboard fighting a "No authority found" error in Asterisk. This seems to come up pretty regularly when I bring up new IAX trunks, but this one was an old trunk I was trying to recover. I'm not sure if this is a new feature in Asterisk 13 or what, but turns out that incoming matching rules only look at "type=user" (or "type=friend") entries. That's different from SIP channels which will match on either one. So lesson learned.

tags: 

Asterisk "(null)" SDP

I configured a trunk between two Asterisk boxes. The one is behind a NAT and was able to register to the other with no problem, but calls failed with a cryptic message that DNS resolution for "(null)" failed. Looking at a SIP packet capture, I saw something to this effect:

Contact: <sip:s@(null);transport=TCP>

tags: 

Blank Page After Owncloud Upgrade

OwncloudI upgraded Owncloud from version 7 to version 8 using the Debian package repos. In the process, something must have gone wrong because the website now showed just a blank page. Curiously, the app continued to work.

Nothing showed up in the Apache server logs, nor anywhere else that I could find. Finally I opened up index.php and started tracing through the code. Turns out I was getting an exception with a description of

Pages

Subscribe to zmonkey.org RSS Subscribe to zmonkey.org - All comments