Monthly Archives: September 2012

Unix tail -f equivalent in Windows PowerShell

One of my favorite ways of monitoring jobs from the Unix command line was to tail an output file using the -f switch.  This way I could see updates to my screen as they were written to the file.  It is a good progress indicator for jobs that are active:

tail -f filename.txt

I always wanted an equivalent command in Windows PowerShell, but I was unable to find it until a colleague of mine pointed me in the right direction this week.  The PowerShell syntax is:

get-content -Path “C:\filename.txt” -Wait

Now I monitor jobs just as well in Windows!  Thanks Will!

Find Failed Files in Robocopy

I copied 123 GB of data between two drives using Robocopy; over thirty-seven thousand files, with one failure.  My output log was over 2 MB!  Great!  How do I find this needle in the haystack?  All I want to do is find one failed file in my Robocopy output file.

Total    Copied   Skipped Mismatch  FAILED    Extras
Dirs :        2620         4         0        0       0         0
Files :      37646     24518     13127        0       1         0
Bytes :  123.116 g  99.967 g  23.148 g        0       0         0
Times :    0:03:13   0:00:46                     0:00:30  0:01:57


Speed : 2329557600 Bytes/sec.
Speed : 133298.355 MegaBytes/min.
Ended : Friday, September 28, 2012 10:53:51 AM

I determined that searching for the word ERROR in the output file will find the rows in the log file indicating the reason for the failure.


New File           0 c:\Data\.lock 2012/09/28 10:50:37 ERROR 32 (0x00000020) Copying File c:\Data\.lock The process cannot access the file because it is being used by another process.


Waiting 30 seconds… Retrying…      New File           0 c:\Data\.lock 2012/09/28 10:51:07 ERROR 32 (0x00000020) Copying File c:\Data\.lock The process cannot access the file because it is being used by another process.


ERROR: RETRY LIMIT EXCEEDED.

Shrink tempdb database in SQL Server

Yesterday I had to shrink the tempdb database on SQL Server.  I follow SQL Server tempdb best practices , but rarely have I shrunk tempdb before.  Despite the discussion on whether or not, or how many files to separate tempdb into, I expanded upon the instructions on how to shrink the tempdb database in SQL Server.

Of the options available, Method 1 Use Transact-SQL commands, has always been my preferred method. This is due to the fact that all three ways require restarting SQL Server, so I favor the one that allows me complete control over the size of the tempdb files.  Nevermind I cannot guarantee tempdb is not in use in my environment like I should have for methods 2 and 3.

When, I follow Method 1 for shrinking tempdb, I:

1.Stop SQL Server.  You can do this from SQL Server Management Studio (SSMS) by right-clicking on your server instance and selecting Stop .

2.  Start SQL Server in minimal configuration mode.  At a command prompt, type the following command to start SQL Server:

sqlservr -c -f

In minimum configuration mode tempdb has a size of 1 MB for the data file and 0.5 MB for the log file.

Note If you are unable to start SQL Server, you may need to navigate to “Program
Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\”

If you use a SQL Server named instance, you must change to the appropriate folder (Program Files\Microsoft SQL Server\MSSQL$instance name\Binn) and use the -s switch (-s%instance_name%).

3.Connect to SQL Server by using Query Analyzer, and run the following Transact-SQL commands:

Syntax
ALTER DATABASE tempdb MODIFY FILE
(NAME = ‘tempdev’, SIZE = target_size_in_MB)
— Target size for the data file

ALTER DATABASE tempdb MODIFY FILE
(NAME = ‘templog’, SIZE = target_size_in_MB)
— Target size for the log file

Example
ALTER DATABASE tempdb MODIFY FILE
(NAME = ‘tempdev’, SIZE = 2048)
— Set the data file size to 2 GB.

ALTER DATABASE tempdb MODIFY FILE
(NAME = ‘templog’, SIZE = 1024)
— Set the log file size to 1 GB.

4. Stop SQL Server by pressing Ctrl+C at the Command line.

5. Start your SQL Server service in SSMS by right-clicking your SQL Server and clicking Start .

6. Log into SQL Server and verify the size of the tempdb.mdf and templog.ldf files.  You can do this in SSMS by expanding the System Databases folder, Right-click tempdb , choose Properties , and click Files in the left pane.  The tempdb file sizes will be in the right pane.

Print Screen with MacBook Pro

I run Windows 8 on my MacBook Pro, however there is no Print Screen key.  How do I take a screen shot (Print Screen) running Windows on MacBook Pro?

Take a screen shot (Print Screen) with: fn + Shift + F11

You can also capture the active window with: fn + Shift + Alt + F11

Don’t forget, you can also use the Snipping Tool .

Windows 8 – Windows Can’t Be Activated Right Now

I installed Windows 8 on my computer, but when I went to activate it, I got the error message “Windows Can’t Be Activated Right Now”.  How do I activate Windows 8?  Follow these steps to activate Windows 8.

To resolve activating Windows 8:
1. Hit the START key.  Alternatively, select SEARCH from the right hand side of the screen.
2. Type RUN
3. Type slui 3 and ENTER .  This opens the Windows Activation window where you can enter a product key to activate Windows.  SLUI 3 is the change product key window.
4. Type in your product key and click Activate .

Eye in the Sky

I walked by a construction site today while three men stood atop a small embankment.  Just another day at the site?  Oh no!  They caught my attention because one was handling a piece of headgear that I later determined were pair of goggles.  Another gentleman was carrying a large laptop looking device held against his torso.  It was strapped around his neck like a walking concessions vendor at a local ball park.  But instead of selling franks, he was looking towards the sky.  When I finally followed his line of sight, I saw what he was doing.  He was piloting an aerial drone.

This is not your dad’s (or son’s, OK…. or your) remote control helicopter or plane! The drone was similar to the hexacopter.

In addition to the many propellers, the drone had an on board camera.  The guy wearing the goggles was surveying the site from the air.  He would guide the pilot and tell him where to maneuver based on what he wanted to see.

I was amazed at how smoothly the flying device handled.  Not to mention silently.  The application of technology was truly amazing.  How often is it that we wish we could see things from a different point of view?  This team had an excellent bird’s eye view of their work.  It occurred to me very quickly how the cost of operating an aerial robot could be more cost effective than chartering a helicopter for the same time.  Not to mention it could fly far lower and be less disturbing.

What a great technology application!