Menu:

Scheduling a job in Linux Server from a Windows Server.

 

 

The requirement is to standardize job scheduling for all Oracle environments in Windows and Linux.

 

  1. Create a login in Linux server for windows account (winsvcuser), put the account in twdbas, twsas and oinstall account (oninstall is required to run Oracle backup)
  2. Install cygwin client with ssh in Windows server.
  3. Generate public and private keys in windows server while logged in as the user that will be submitting a job (twidprd\winsvcuser)

 

D:\cygwin\bin\ssh-keygen –t rsa

 

This generates keys under C:\Documents and Settings\winsvcuser\.ssh folder.

 

  1. Copy id_rsa.pub to Linux server and while logged in as winsvcuser account copy the contents into authorized_keys file

 

Cat id_rsa.pub >> ~/.ssh/authorized_keys

 

Create a file ssh_prime in C:\Documents and Settings\winsvcuser\.ssh folder of windows server as

 

#!/bin/bash

# Creates an ssh-agent, writes ssh agent info

# to the file '~/.ssh-agent-info-`hostname`' and then prompts

# user for keys.  Then any shell can use the agent

# by sourcing the contents of ~/.ssh-agent-info-`hostname`:

#  . ~/ssh-agent-info-`hostname`

ssh_info_file=/cygdrive/c/"Documents and Settings"/winsvcuser/.ssh/.ssh-agent-info-`hostname`

ssh-agent > "$ssh_info_file"

chmod 700 "$ssh_info_file"

. "$ssh_info_file"

ssh-add /cygdrive/c/"Documents and Settings"/winsvcuser/.ssh/id_rsa

           

ssh_prime needs to be run once after reboot. So create a windows scheduler job to run a batch file at reboot.

 

-- This part is not working, it can’t find ssh-agent command in the script, work around is to run ssh_prime manually by starting a bash shell. You will need to enter passphrase for this.

 

The server will submit a job using atd daemon in Linux, so this service must be enabled and winsvcuser must be allowed to use it.

 

Login as root in Linux server and configure atd to start at reboot

 

Chkconfig –level 345 atd on

Start service atd

 

Edit /etc/at.allow and add a line winsvcuser

 

Create a bash script (job1.sh) for the job to run. This script schedules a hourlyrmanarch_DB1.sh script after two minutes.

 

#!/bin/bash

. /cygdrive/c/Documents\ and\ Settings/winsvcuser/.ssh/.ssh-agent-info-`hostname`

ssh gotodba1 at -f /apps/backup/scripts/hourlyrmanarch_DB1.sh now + 2 minutes

 

To schedule a job run following command

 

d:\cygwin\bin\bash --login -c "bash /cygdrive/c/Documents\ and\ Settings/winsvcuser/.ssh/job1.sh"