2011-08-06 4 views
0

私のスクリプト:nohupを使用してコマンドを実行すると非常に混乱しますか?

#!/bin/bash 
. /home/was/.bash_profile 
export PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/was/bin:/wasdata/oracle/10.2.0/client_1/bin: 

    sqlplus "mon_system/[email protected]" <<eof 
    set echo off 
    set feedback off 
    set serveroutput on 
    set term off 
    set sqlprompt "" 
    set linesize 200 
    spool /wasdata/scripts/systeminf/tmp-was-restart.sh 
    exec prc_auto_restart 
eof 
    sed -i '/prc_auto_restart/d' tmp-was-restart.sh 
    /wasdata/scripts/systeminf/tmp-was-restart.sh 
    cat /dev/null>/wasdata/scripts/systeminf/tmp-was-restart.sh 

プロセスは次のとおりです。 1つのログインデータベースに手順「prc_auto_restart」を実行するために 2手続きます出力「/wasdata/scripts/systeminf/tmp-was-restart.sh私はSCRI実行すると

ssh [email protected] "ps -ef|grep was1.*WebSphere.*c01_ship_s01|grep -v "grep">>kill.log;ps -ef|grep was1.*WebSphere.*c01_ship 
_s01|grep -v "grep"|awk '{print \"kill -9 \" \$2}'|sh" 

を:tmp-was-restart.shが好きになるでしょう

"/wasdata/scripts/systeminf/tmp-was-restart.sh」 3は、実行します"直接、スクリプトの動作PT:

[[email protected] systeminf]$ ./prod-auto-restart.sh 

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Aug 6 16:33:08 2011 

Copyright (c) 1982, 2005, Oracle. All rights reserved. 


Connected to: 
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production 
With the Partitioning, Real Application Clusters, OLAP and Data Mining options 

SQL> SQL> SQL> SQL> SQL> ssh -t -t [email protected] "ps -ef|grep was1.*WebSphere.*c01_ship_s01|grep -v "grep">>kill.log;ps -ef|grep was1.*WebSphere.*c01_ship_s01|grep -v "grep"|awk '{print \"kill -9 \" \$2}'|sh" 
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production 
With the Partitioning, Real Application Clusters, OLAP and Data Mining options 
Connection to 10.10.4.212 closed. 
[[email protected] systeminf]$ 

しかし、私は、スクリプトを実行するnohupを使用します。

[[email protected] systeminf]$ nohup prod-auto-restart.sh & 
[1] 29983 
[[email protected] systeminf]$ nohup: appending output to `nohup.out' 


[1]+ Stopped     nohup prod-auto-restart.sh 
[[email protected] systeminf]$ 
[[email protected] systeminf]$ 
[[email protected] systeminf]$ ps -ef|grep autp 
was  30014 27492 0 16:33 pts/4 00:00:00 grep autp 
[[email protected] systeminf]$ ps -ef|grep auto 
was  29983 27492 0 16:33 pts/4 00:00:00 /bin/bash prod-auto-restart.sh 
was  30003 29983 0 16:33 pts/4 00:00:00 /bin/bash prod-auto-restart.sh 
was  30021 27492 0 16:33 pts/4 00:00:00 grep auto 

それは、それは2つのシェルをフォークします、と私はtmp-was-restart.shをチェック"/ sas -i '/ prc_auto_restart/d' tmp-was-restart.sh"コマンドが正しく実行され、 "/wasdata/scripts/systeminf/tmp-was-restart.sh"で停止したことを意味します。私はプロセス29983、 "/wasdata/scripts/systeminf/tmp-was-restart.sh"コマンドを実行したが、 "cat/dev/null>/wasdata/scripts/systeminf/tmp-was-restart.sh "not execuテッド、非常に混乱している!

+0

これを中止する人はいますか? – koko

答えて

0

Stoppedメッセージの最も一般的な理由は、スクリプトがユーザーからのコマンドライン経由の入力を期待していることです。通常はreadコマンドです。投稿したコードには何も表示されないので、表示されていない子スクリプトがある場合は、そこにreadをチェックしてください。スクリプトが 'Ctrl-S'(停止)文字を受け取った可能性は非常に低いですか?信号。

sqlplusの使用法は正しいようですが、sqlplusにアクセスして理論をテストすることはできませんので、sqlplusのcmd-lineの使用方法をダブルチェックしてください。-nオプション(ORその他) 'いいえ、コマンドラインの対話'。

最後に、シェルのデバッグモードが役立つかもしれません。

PS4='$LINENO>'; set -vxをスクリプトの先頭近くに試してください。アウトプットを読む方法を理解するには、少し学習が必要です。 -vオプションは、評価されるコードブロックをif .. ; then ; ... else ; ... fi ,,またはwhile ... doneまたは単一のパイプラインとして表示します。

こちらがお役に立てば幸いです。

P.S.あなたが新しいユーザーのように見えるように、あなたがそれを受け入れられたものとして覚えておいてください、そして/または役に立つ答えとして+(または - )を付けるのを助ける答えを得たら。

+0

こんにちはシェルター、あなたのanswer.Butのためにありがとう – koko

+0

のいずれかの主なスクリプトまたはスクリプトを作成した読み取りコマンドがありません、最も混乱していることは、なぜ私は直接コマンドを実行するときに動作するのですか? – koko

+0

こんにちはシェルター、私はあなたがここで停止したスクリプトをデバッグするために述べたコマンドを使用します:18> sed -i/prc_auto_restart/d tmp-was-restart.sh /wasdata/scripts/systeminf/tmp-was- restart.sh 19 /wasdata/scripts/systeminf/tmp-was-restart.sh tcsetattr:入出力エラー – koko

関連する問題