Linux script 命令記錄(資料庫)操作步驟

來源:互聯網
上載者:User

對DBA而言,經常碰到升級資料庫或是apply patch,以及有些時候需要運行大量的指令碼。對於這些操作我們希望現在在螢幕同時又輸出的檔案以備後續查詢過程中曾經丟失的步驟或錯誤。Linux下的script命令就是解決這個問題的好幫手。

1、script命令描述

script命令會記錄所有的操作到檔案同時在螢幕上輸出,直到終止登陸的會話,或使用CRTL+D,或使用exit退出則停止記錄。
這個命令對於資料庫的升級或是重要設定的情形下使用可以用於後續查詢操作成功或失敗。
用法: $ script [upgrade.log]
如果未指定記錄檔名的情形,自動組建記錄檔檔案名稱為typescript。
如果需要輸出到已經存在的記錄檔,則使用 -a 參數,再接已經存在記錄檔名。
如果需要在輸出到記錄檔的同時,也可以查看記錄檔的內容,可以使用 -f 參數。

# script 協助描述
robin@SZDB:~> man script
NAME
    script - make typescript of terminal session

SYNOPSIS
    script [-a] [-c COMMAND] [-f] [-q] [-t] [file]

DESCRIPTION
    Script makes a typescript of everything printed on your terminal.  It is useful for students who need a hardcopy record of
    an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).

    If the argument file is given, script saves all dialogue in file.  If no file name is given, the typescript is saved in the
    file typescript.

    Options:

    -a      Append the output to file or typescript, retaining the prior contents.

    -c COMMAND
            Run the COMMAND rather than an interactive shell.  This makes it easy for a script to capture the output of a pro-
            gram that behaves differently when its stdout is not a tty.

    -f      Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and
            another can supervise real-time what is being done using `cat foo'.

    -q      Be quiet.

    -t      Output timeing data to standard error. This data contains two fields, separated by a space. The first field indi-
            cates how much time elapsed since the previous output. The second field indicates how many characters were output
            this time. This information can be used to replay typescripts with realistic typing and output delays.

  • 1
  • 2
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.