xshell 录制服务器操作步骤日志
2020-02-17 本文已影响0人
HongXunPan
背景
在很多时候,譬如写博客教程的时候,需要记录服务器操作步骤的命令和结果。大多数情况下要边执行命令边复制或者截图记录到文档,这样的效率并不高而且会终端思路引起错误操作等。
录制日志设置
xshell 文件-属性(快捷键Alt+P)
文件-属性属性-日志记录
日志选项切记不要勾选 包括终端代码,否则可能会出现乱码等情况:
[BEGIN] 2020/2/17 12:42:54
Last login: Mon Feb 17 04:04:15 2020 from 10.0.2.2
[vagrant@homestead: ~�[vagrant@homestead:~]$ pwd
/home/vagrant
[vagrant@homestead: ~�[vagrant@homestead:~]$ ll
total 120
drwxr-xr-x 12 vagrant vagrant 4096 Dec 29 09:46 �[0m�[01;34m.�[0m/
drwxr-xr-x 3 root root 4096 Jun 3 2018 �[01;34m..�[0m/
-rw-r--r-- 1 root root 6920 Dec 20 06:36 .bash_aliases
-rw------- 1 vagrant vagrant 11046 Feb 17 04:04 .bash_history
-rw-r--r-- 1 vagrant vagrant 220 Jun 3 2018 .bash_logout
-rw-r--r-- 1 vagrant vagrant 3773 Jul 26 2018 .bashrc
drwx------ 4 vagrant vagrant 4096 Jun 3 2018 �[01;34m.cache�[0m/
drwxrwxr-x 4 vagrant vagrant 4096 Nov 27 08:12 �[01;34m.composer�[0m/
-rw-rw-r-- 1 vagrant vagrant 4 Jul 25 2018 composer.json
drwxr-xr-x 4 vagrant vagrant 4096 Jun 3 2018 �[01;34m.config�[0m/
drwx------ 3 vagrant vagrant 4096 Jun 3 2018 �[01;34m.gnupg�[0m/
drwxr-xr-x 3 vagrant vagrant 4096 Jun 3 2018 �[01;34m.local�[0m/
-rw-r--r-- 1 root root 61 Dec 20 06:37 .my.cnf
-rw------- 1 vagrant vagrant 322 Jul 18 2018 .mysql_history
drwxrwxr-x 2 vagrant vagrant 4096 Jun 12 2018 �[01;34m.ngrok2�[0m/
drwxr-xr-x 6 vagrant vagrant 4096 Dec 13 07:36 �[01;34m.npm�[0m/
drwxr-xr-x 11 vagrant vagrant 4096 Jun 3 2018 �[01;34m.oh-my-zsh�[0m/
-rw-r--r-- 1 vagrant vagrant 888 Dec 20 06:36 .profile
-rw------- 1 vagrant vagrant 554 Jan 15 07:26 .rediscli_history
drwxr-xr-x 2 vagrant vagrant 4096 Oct 16 07:22 �[01;34m.rpmdb�[0m/
drwx------ 2 vagrant vagrant 4096 Jun 12 2018 �[01;34m.ssh�[0m/
-rw-r--r-- 1 vagrant vagrant 0 Jun 3 2018 .sudo_as_admin_successful
-rw-r--r-- 1 vagrant vagrant 5 Jun 3 2018 .vbox_version
-rw------- 1 vagrant vagrant 10360 Dec 25 03:44 .viminfo
-rw-r--r-- 1 vagrant vagrant 298 Jun 12 2018 .wget-hsts
-rw-r--r-- 1 vagrant vagrant 3169 Jun 3 2018 .zshrc
[vagrant@homestead: ~�[vagrant@homestead:~]$ exit
logout
Connection closed by foreign host.
Disconnected from remote host(vagrant) at 12:43:10.
Type `help' to learn how to use Xshell prompt.
�[K�[1;32m[c:\~]$ �[m
[END] 2020/2/17 12:43:16
属性-终端
设置编码录制日志
开始录制日志 得到日志文件以下为正常日志
[BEGIN] 2020/2/17 12:45:15
Last login: Mon Feb 17 04:44:59 2020 from 10.0.2.2
[vagrant@homestead:~]$ ll
total 120
drwxr-xr-x 12 vagrant vagrant 4096 Dec 29 09:46 ./
drwxr-xr-x 3 root root 4096 Jun 3 2018 ../
-rw-r--r-- 1 root root 6920 Dec 20 06:36 .bash_aliases
-rw------- 1 vagrant vagrant 11068 Feb 17 04:43 .bash_history
-rw-r--r-- 1 vagrant vagrant 220 Jun 3 2018 .bash_logout
-rw-r--r-- 1 vagrant vagrant 3773 Jul 26 2018 .bashrc
drwx------ 4 vagrant vagrant 4096 Jun 3 2018 .cache/
drwxrwxr-x 4 vagrant vagrant 4096 Nov 27 08:12 .composer/
-rw-rw-r-- 1 vagrant vagrant 4 Jul 25 2018 composer.json
drwxr-xr-x 4 vagrant vagrant 4096 Jun 3 2018 .config/
drwx------ 3 vagrant vagrant 4096 Jun 3 2018 .gnupg/
drwxr-xr-x 3 vagrant vagrant 4096 Jun 3 2018 .local/
-rw-r--r-- 1 root root 61 Dec 20 06:37 .my.cnf
-rw------- 1 vagrant vagrant 322 Jul 18 2018 .mysql_history
drwxrwxr-x 2 vagrant vagrant 4096 Jun 12 2018 .ngrok2/
drwxr-xr-x 6 vagrant vagrant 4096 Dec 13 07:36 .npm/
drwxr-xr-x 11 vagrant vagrant 4096 Jun 3 2018 .oh-my-zsh/
-rw-r--r-- 1 vagrant vagrant 888 Dec 20 06:36 .profile
-rw------- 1 vagrant vagrant 554 Jan 15 07:26 .rediscli_history
drwxr-xr-x 2 vagrant vagrant 4096 Oct 16 07:22 .rpmdb/
drwx------ 2 vagrant vagrant 4096 Jun 12 2018 .ssh/
-rw-r--r-- 1 vagrant vagrant 0 Jun 3 2018 .sudo_as_admin_successful
-rw-r--r-- 1 vagrant vagrant 5 Jun 3 2018 .vbox_version
-rw------- 1 vagrant vagrant 10360 Dec 25 03:44 .viminfo
-rw-r--r-- 1 vagrant vagrant 298 Jun 12 2018 .wget-hsts
-rw-r--r-- 1 vagrant vagrant 3169 Jun 3 2018 .zshrc
[vagrant@homestead:~]$ pwd
/home/vagrant
[vagrant@homestead:~]$ exit
logout
Connection closed by foreign host.
Disconnected from remote host(vagrant) at 12:45:27.
Type `help' to learn how to use Xshell prompt.
[END] 2020/2/17 12:45:32