bookmark_borderCheck if a Device or File System is Mounted

Occasionally I find myself needing to mount a remote file system on a local *BSD or Linux machine. On one such occasion recently I had mounted an NFS file system from a Network Attached Storage (NAS) server to a local machine running FreeBSD, for the purpose of backing up some of the files to yet another machine offsite using the rsync utility. I had created a little script to run rsync periodically through cron. This script worked well until I noticed a few days later that the backups on the remote machine no longer existed. After some investigation I quickly determined that NAS file system was no longer mounted on the FreeBSD machine (I can neither confirm or deny that I may have configured something incorrectly). The rsync script, upon noticing that files no longer existed in the source, deleted said files at the target. It was at that point that I decided to include a small test in the rsync script to check on the existence of the mounted file system; then, if it still existed, the script would proceed with the rsync command, else it would write an error message to a log. Here is the code snippet I used in the script, which you can easily adapt for other situations:

The df command simply displays statistics about the amount of free disk space on the specified file system. If a file system argument is not specified, statistics for all mounted file systems are displayed. The output of the df command is then piped through the venerable grep utility using its -q option, which instructs grep not to write anything to standard output, but rather exit immediately with a zero status if a match is found. Finally, the file system we’re interested in matching to, parsed from the output of the df command, is provided to grep. If the output of this df command is zero, the script runs a command (in this case my rsync command), else if it exits with anything other than zero, the script runs another command instead (in this case an error message).

bookmark_borderHow to Fix Duplicate Title and Meta Tags When Spanning Multiple Home Pages in WordPress

This post describes how to fix duplicate meta and title tag content when spanning multiple home pages in WordPress. This isn’t a topic I normally cover here at www.iceflatline.com, but after searching for a solution to this problem for this site and continually encountering advice such as just add a plugin, I decided to post how I fixed this problem without encumbering my site with yet another WordPress plugin or other solutions.

The Problem

Like each post here at iceflatline.com, my index or main “home” page contains its own unique description and keywords meta tags and title tag content. WordPress allows me to determine the number of posts displayed on my home page (I typically choose five). Once this limit is reached, my WordPress theme automatically generates an “Older Entries” link at the bottom of the page, allowing the reader to navigate to a another page containing the previous five posts, and so on. While this is a helpful navigation feature for the reader, to a search engine like Google it’s another URL that contains the same meta and title tag content as that of the main home page. For example, I use the following content for my home page description and keywords meta tags:

Left unchanged, however, each Older Entries link will also contain the same description and keywords content. Consequently, tools like Google’s Webmaster Tools will complain that it has detected duplicate meta descriptions. This issue likely won’t prevent your site from appearing in search results, but paying attention to it can provide Google and other search engines with more information and help drive traffic to your site.

The Solution

To fix the problem of duplicate meta and title content I added a bit of PHP code to my theme’s header.php file. When a reader of iceflatline.com uses the Older Entries link to view a page containing its previous five posts, this code will automatically prepend or append a page number to the contents of these tags so that the metadata in each of these pages appears unique to the search engine. The page numbering starts with 2 and increments each time the reader navigates to a previous page.

    Duplicate Meta Tag Content

To eliminate duplicate description and keywords meta tag content, I added the following PHP code to my theme’s header.php file:

Now when someone clicks on Older Entries the description and keywords meta tag content will be prepended with a page number so that it looks like this:

If desired, the following variations of the code above will append the page numbers instead:

    Duplicate Title Tag Content

To eliminate duplicate title tag content, I appended the following PHP code to the tag’s existing contents in my theme’s header.php file:

Combined with the original code, the revised PHP code within the title tags now looks like this:

Now when someone clicks on Older Entries the title description will be appended with a page number so that it looks like this:

Conclusion
There ya have it. A bit PHP code and I fixed these nagging problems, and saved myself the hassle of having to update and manage yet another WordPress plugin or use some other solution that didn’t fully meet my needs.

iceflatline