Oracle Database Blog: Experiments & Learnings

September 17, 2011

Run DataGuard Observer in Background on Windows

Filed under: Oracle RDBMS — Tags: , , — Saurabh Manroy @ 4:14 pm

As DBAs, some technical decisions are out of our hands. One of such case is when management suggests..hmm…rather decides to monitor the DG configuration from a third site which is good but remote site hosts Microsoft Windows. Because “start observer” command doesn’t return control to the user, a non-trivial question for a DBA is: how would observer run in background on Windows ? On Unix ‘&’ is the magic character to achieve this and when combined with nohup and Screen it does wonders.

Well, if you have a programming background with a bit of hands-on experience with Visual Basic, VC++ or Java, it shouldn’t be tough to make a small program to achieve this goal (something in Visual basic… may be setting WindowSize to zero) or Create a Service that can run a batch file. Batch file would contain commands to run observer.

A service creation tool that is available with Microsoft windows installation is : sc.exe which can be invoked from DOS Command Prompt to create service. But it is not able to read simple “.bat” or “.cmd” files. Its more for executable applications (notepad.exe/calc etc.).  Here is what I tried with sc.exe tool:

c:\> sc.exe create ObserverDG binPath= c:\observer.bat
-- contents of observer.bat
C:\app\product\11.2.0\client_1\bin\dgmgrl -silent sys/Oracle123@orcl "start observer"

Starting the service gives Error:1053

So, even if I was able to create a service this way, service didn’t start.

Another option is to use software which can run batch files in background on Windows.

a.) HSTART software from ntwind –> For commercial Use, a license is needed. Cost is around 20$ per user (as on 17th Sep 2011).

b.) SilentCMD software : FreeWare, No license Needed.

Both Software don’t have any installation files. Simple and easy to use.

DGMGRL> show configuration;

Configuration - DG_SOL

  Protection Mode: MaxAvailability
    ORCL  - Primary database
    STDBY - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

Logon to the Windows host and create a batch file (.bat) with following contents:

-- contents of observer.bat
C:\app\product\11.2.0\client_1\bin\dgmgrl -silent sys/Oracle123@orcl "start observer"

Next step is to download HSTART or SilentCMD software.

C:\> hostname
-- run hstart with /Noconsole switch
c:\> hstart.exe /NOCONSOLE "c:\observer.bat";
--or Run SilentCMD
C:\SilentCMD_1.0.2> SilentCMD.exe c:\Observer.bat

And we are done. Lets confirm if everything is alright.

DGMGRL> enable fast_start failover
DGMGRL> show configuration

Configuration - DG_SOL

  Protection Mode: MaxAvailability
    ORCL  - Primary database
    STDBY - (*) Physical standby database

Fast-Start Failover: ENABLED

Configuration Status:

-- On Primary database

---------------------- ------------------------------ ------- ----------------------------------------
SYNCHRONIZED           STDBY                          YES     SaurabhManroy

Another option that I have not explored is using Windows Task Scheduler, which can also run batch files.

Edit (20/Sep/2011): Aforementioned third party software work only if session doesn’t log off. These are good only for hiding windows. If using remote desktop connection to server, just close the window of remote desktop rather than logging off. Ask Windows Server administrator to modify settings so that your session never logs off automatically. A dirty workaround !

Some software like Fire Daemon (from Firefox) may suite your needs.  Or a software that can read non-application batch files (like the one we are using) and create a service using those batch files.

Edit (28/Mar/2012):  PSExec  is a useful tool  (have a look at comment from Hans) which allows the batch file to run as a system user. That means, you can log on an log off any number of times and the command would still continue to run.



  1. Searching for the same thing, I also found ‘psexec.exe’ from sysinternals (now inside Microsoft).

    You might want to try ‘psexec -s -d c:\observer.bat’

    No guarantees – that is a direction I still need to investigate.

    Comment by Hans — March 27, 2012 @ 5:21 pm

    • Hello Hans,

      Nice find. Switch ‘-s’ looks promising to help run the batch as system user (which allows user to log off) and “-d” puts it in the background.
      I would update the blog entry as well.

      Saurabh Manroy

      Comment by Saurabh Manroy — March 28, 2012 @ 1:48 pm

  2. Hi
    is it possible to avoid installing third party utilities and execute the batch file directly using:

    C:\windows\system32\cmd.exe /C c:\observer.bat

    Possibly you could also use the sc command to create the service

    Comment by Anonymous — June 9, 2012 @ 9:52 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: