UNIX‎ > ‎

Unix Tips - 3

Customizing start script

NO HANGUP 

 
After creation of WebLogic domain in most of the cases we need to customize the start script to run in Unix environmnet with out hung even when user terminal window closed. Normally most of WLA are connecting the Unix machine (Solaris or HP-UX) Connect through the SSH or Putty.
 
If user issue startWebLogic.sh command to start the WebLogic server and the SSH or Putty window closed the process also stopped. 
Here I suggest you create a shell script that will starts up you WebLogic Server and also keep alive forever. Name the script as 'startAdmin.sh' or your convience.
 
clear
nohup /export/home/wluser/domains/wlscldom/startWebLogic.sh >>$HOME/$USERNAME.log 2>&1 &
echo tail -f $HOME/$USERNAME.log
 
USERNAME you can replace with your servername also.
 
Now letus understand what above script will perform for us.
 
1. nohup .. This command will run the Unix process @ Server Side without terminal window. that is if w
e close the SSH or Putty window even though the WebLogic server should start.
2. Redirecting the console log using filter >> user can specify the desired log location here. And here the standard error(2) is redirecting(>) to standard output(&1). This log extension some of users using as .out because it is standard output of console and some other using as .log.
3. To run the 'startWebLogic.sh' script in backgroud use '&'.
4. Then tail the redirected log file path.
 

To redirect your Stderr to separate File

In your StartWebLogic.sh script you need to modify the JAVA_OPTION as follows
 
-Dweblogic.Stderr=$HOME/logs/adminSError.log.
 
This will redirect your JVM generating Standard Errors to specified log path.

The grep command for Troubleshooting


When you are in trouble shooting you might need to search for bunch of words in the log files. You are on Unix machines you have wonderful command grep. You might need to grep the sentence instead of words. This could be rare requirement but it will make your work much better than regular grep command.
egrep -i 'search pharse in a sentance' searching.txt

There could be error saying that Binary file  while doing grep the file might be data. grep command can be applied only on ASCII Text file.
$  grep 'Exception' Trace.log
Binary file Trace.log matches

Whenever you encounter above error check the file type. If it is other than ASCII text file in Linux file system this usually happens.
$ file Trace.log
Trace.log: data

Normally grep command can be applicable only when the file is ASCII text file. Now let us see WebLogic server generated instance log file saved as managed1.out
$ file managed1.out
managed1.out: ASCII English text, with very long lines

Resolution :  Use 'strings' command to convert the binary file to ASCII text. Then send it to grep command.
strings binaryContaind.log | grep "Pattern"

Amazon.com Widgets

Remote script execution


Some situations demands that you want to run a bash/sh shell script on every machine. If you have SSH  password less connectivity then you can do simply do the following trick:
 ssh user@remotehost 'bash -s' < commonScript.sh

or
To execute few commands on remote machine 

ssh user@host
<<'ENDSH'
#commands to run on remote host
ENDSH

Critical demand on the above command that you need to pass arguments. How to do??
No worries!!! just export the ARG(s) you wish to pass.
export ARG1='/my/home/path'
ssh user@remotehost
'bash -s' <<'ENDSH'
 
# commands to run on remote host
  echo $ARG1
ENDSH

To make DNS search

Some of the troubles raises because of DNS entries unresolved, DNS Configurations of a Solaris machine will be available in the /etc/resolv.conf file.You can check that and validate the content so that you can identify the bottleneck for the network issues.
 
cat /etc/resolv.conf
 
 
If you feel this site is useful to you and want to know updates on this site... Please subscribe to this site with your Google account.

Ċ
BHAVANI SHEKHAR,
Dec 7, 2010, 2:51 PM
Comments