通过 tail 命令,可以查看文件结尾的十行。这将有助于查看日志文件的最后十行来阅读重要的系统消息。还可以使用 tail 来观察日志文件被更新的过程。使用 -f 选项,tail 会自动实时地把打开文件中的新消息显示到屏幕上。
这是它的一个功能介绍,从这里看不出它的一点威力。但如果设想现在正在运行一个脚本,这个脚本的作用是要进行几百万条oracle数据库记录的导入。这个过程可能要耗时几个小时。
$ more 2-imp.sh
imp xiaodon/xiaodon@xiaodon tables=EA_CROSS_SYS_DATA_TBL_OLD COMMIT=Y IGNORE=Y file='EA_CROSS_SYS_DATA_TBL_OLD_01.dmp,EA_CROSS_S
YS_DATA_TBL_OLD_02.dmp,EA_CROSS_SYS_DATA_TBL_OLD_03.dmp,EA_CROSS_SYS_DATA_TBL_OLD_04.dmp' BUFFER=300000000 FEEDBACK=3000 log=imp-EA_
CROSS_SYS_DATA_TBL_OLD-xiaodon.log
imp xiaodon/xiaodon@xiaodon tables=EA_CROSS_SYS_DATA_TBL_OLD COMMIT=Y IGNORE=Y file='EA_CROSS_SYS_DATA_TBL_OLD_01.dmp,EA_CROSS_S
YS_DATA_TBL_OLD_02.dmp,EA_CROSS_SYS_DATA_TBL_OLD_03.dmp,EA_CROSS_SYS_DATA_TBL_OLD_04.dmp' BUFFER=300000000 FEEDBACK=3000 log=imp-EA_
CROSS_SYS_DATA_TBL_OLD-xiaodon.log
我当然不希望这个过程在我不知情的情况下中止掉。在这里,tail -f的强大就体现出来了。我可以通过监视日志文件来了解整个过程的进度。
$tail -f imp-EA_CROSS_SYS_DATA_TBL_OLD-xiaodon.log
Connected to: Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.5.0 - Production
Connected to: Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.5.0 - Production
Export file created by EXPORT:V09.02.00 via direct path
import done in US7ASCII character set and UTF8 NCHAR character set
import server uses UTF8 character set (possible charset conversion)
IMP-00046: using FILESIZE value from export file of 26843545600
. importing EAI_CT_BUILD's objects into EAI_CT_BUILD
. . importing partition "EA_CROSS_SYS_DATA_TBL_OLD":"EA_CROSS_SYS_DATA_WENZHOU"
..............................................
import done in US7ASCII character set and UTF8 NCHAR character set
import server uses UTF8 character set (possible charset conversion)
IMP-00046: using FILESIZE value from export file of 26843545600
. importing EAI_CT_BUILD's objects into EAI_CT_BUILD
. . importing partition "EA_CROSS_SYS_DATA_TBL_OLD":"EA_CROSS_SYS_DATA_WENZHOU"
..............................................
通过不停增长的点来了解整个过程的进度。如果在这本脚本运行的时间又想干些其它的事情,可以按CTRL-c来结束tail命令。做完了其它的,可以通过再次运行tail -f来查看这个log文件。