序号 | 录入时间 | 录入人 | 备注 |
---|---|---|---|
1 | 2016-09-30 | Alfred Jiang | - |
Mac 系统 - 通过 Shell 脚本自动记录 Terminal 活动
Mac 系统 \ Terminal \ 终端
- 自动记录 Terminal 活动以便于查找出错的地方
/usr/bin/script ~/Desktop/Terminal.log
编写以时间为序命名的小脚本来保存每一次对话脚本 logger.sh
#!/bin/bash
# logger.sh
# Log everything you do in Terminal.
#* Formatted date & time string.
FORMATTED_DATE=`/bin/date "+%Y-%m-%d-%H.%M.%S"`
#* Archive the previous file
if [ -f ~/Desktop/Logs/Terminal.log ]; then
/bin/cp -f ~/Desktop/Logs/Terminal.log{,.$FORMATTED_DATE.txt}
fi
#* Create Logs Directory
if [ ! -d "~/Desktop/Logs" ]; then
mkdir ~/Desktop/Logs
fi
#* Begin a new one
/usr/bin/script ~/Desktop/Logs/Terminal.log
执行
sh logger.sh
(无)
(无)