°Ô½Ã¹° 1,369°Ç
   
history - script, scriptreplay ¸í·É¾î °ü¸®
±Û¾´ÀÌ : ÃÖ°í°ü¸®ÀÚ ³¯Â¥ : 2019-11-28 (¸ñ) 13:25 Á¶È¸ : 1707
±ÛÁÖ¼Ò :
                                


¸®´ª½º ȯ°æ¿¡¼­ ´ë°³´Â history ¸í·É¾î¸¦ ÀÌ¿ëÇÏ¿© »ç¿ëÇÑ ¸í·É¾îµéÀ» ÃßÀû °ü¸®ÇÑ´Ù.
¿©±â¼­ Á¶±Ý ´õ³ª¾Æ°¡¸é ¸í·É¾î¿¡ ³¯Â¥/½Ã°£À̳ª ÀúÀåÇÒ ¶óÀμö ¼³Á¤ÇÏ´Â Á¤µµÀÏ°ÍÀÌ´Ù.

history ¸í·É¾î¿¡ ÇÑ°è´Â °á°ú°ª Ãâ·ÂÀº ±â·ÏµÇÁö ¾Ê´Â´Ù´Â °ÍÀÌ´Ù. ÀÌ°ÍÀú°Í Å×½ºÆ®ÇÏ°í °á°ú¸¦ Á¤¸®ÇÏ´Ùº¸¸é Ãâ·Â°ªÀº ÀüÈÄ»çÇ×À» ºñ±³ÇÒ¶§¿¡ ¹Ýµå½Ã ÇÊ¿äÇÑ ºÎºÐÀÌ´Ù.

script ¸í·É¾î´Â Å͹̳Π¼¼¼ÇÀ» ÆÄÀϷΠĸóÇϰųª ±â·ÏÇϴµ¥ »ç¿ëµÇ´Â µµ±¸ÀÌ¸ç ±â·ÏµÈ ¼¼¼ÇÀº scriptplay ¸¦ ÀÌ¿ëÇؼ­ Àç»ý°¡´ÉÇÏ´Ù. 

script – make typescript of terminal session
scriptreplay – play back typescripts, using timing information


Install
Ubuntu
# apt-get install -y util-linux

CentOS
# yum install -y util-linux



»ç¿ë¹ý
# script {option} {filename}
ÆÄÀϸíÀ» Á¤ÀÇÇÏÁö ¾ÊÀ¸¸é typescript À̶ó´Â ÆÄÀÏ·Î ÀúÀåµÈ´Ù. 

Usage:
script [options] [file]
Make a typescript of a terminal session.

Option
-a, --append append the output
-c, --command <command> run command rather than interactive shell
-e, --return return exit code of the child process
-f,  --flush run flush after each write
       --force use output file even when it is a link
-q, --quiet be quiet
-t[<file>], --timing[=<file>] output timing data to stderr or to FILE
-h, –help display this help
-V, –version display version




cat À̳ª viµîÀ» ÀÌ¿ëÇÏ¿© ÆÄÀÏÀ» ¿­¾îº¸¸é ¸í·É¾î °á°ú°ª°ú ÇÔ²² ±â·ÏÀ» ½ÃÀÛÇÏ°í ³¡³ª´Â ½Ã°£ÀÌ ±â·ÏµÇ¾îÀÖ´Ù.


¿øÇÏ´Â ÆÄÀϸíÀº ¾Æ·¡Ã³·³ ÀԷ°¡´ÉÇÏ´Ù.
# script sessions-log-$(date +%Y-%m%d-%T).txt

¿©·¯ ¿É¼ÇÁß ÇÑ°¡Áö¸¸ ¼Ò°³ÇÏÀÚ¸é -t (timing) ´Â ¸í·É¾î ±â·ÏµéÀ» ½Ã°£º°·Î ³ª¿­ÇÏ¿© Àç»ý ¸í·É¾î(scriptreplay)¿Í  °áÇÕÇÏ¸é ½Ã°£±â·Ï ¼ø¼­´ë·Î shell»ó¿¡¼­ µ¿ÀûÀÎ ¿µ»óó·³ Ç¥ÇöµÇ±âµµ ÇÑ´Ù.
# script –timing=timing.txt session.log
.............................
.............................

# scriptreplay –timing=timing.txt session.log
.............................
.............................

 
·Î±×ÀÎ ¼¼¼Ç¸¶´Ù ÆÄÀÏ·Î ±â·ÏÇÏ·Á¸é ¾Æ·¡Ã³·³ È°¿ë°¡´ÉÇÏ´Ù.
# cat /etc/profile
.............................
.............................

if [ ¡°x$SESSION_RECORD¡± = ¡°x¡± ]
then
timestamp=$(date +%Y-%m%d-%T)
session_log=/var/log/history/session.$USER.$$.$timestamp
SESSION_RECORD=started
export SESSION_RECORD
script -t -f -q 2>${session_log}.timing $session_log
exit
fi

:: ·Î±×ÀúÀå µð·ºÅ丮 
# mkdir /var/log/history
# exit

:: ÀÌÈÄ ·Î±×ÀκÎÅÍ´Â ¼³Á¤ °æ·Î¿¡ ÆÄÀÏ·Î ±â·Ï
# ls -l /var/log/history
-rw-r–r– 1 root root 2592 Nov 28 12:55 session.root.4421.2019-1128-12:54:51
-rw-r–r– 1 root root 1282 Nov 28 12:55 session.root.4421.2019-1128-12:54:51.timing

À̸§ Æнº¿öµå
ºñ¹Ð±Û (üũÇÏ¸é ±Û¾´À̸¸ ³»¿ëÀ» È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.)
¿ÞÂÊÀÇ ±ÛÀÚ¸¦ ÀÔ·ÂÇϼ¼¿ä.
   

 



 
»çÀÌÆ®¸í : ¸ðÁö¸®³× | ´ëÇ¥ : ÀÌ°æÇö | °³ÀÎÄ¿¹Â´ÏƼ : ·©Å°´åÄÄ ¿î¿µÃ¼Á¦(OS) | °æ±âµµ ¼º³²½Ã ºÐ´ç±¸ | ÀüÀÚ¿ìÆí : mojily°ñ¹ðÀÌchonnom.com Copyright ¨Ï www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.