1. HISTTIMEFORMAT 变量:bash3.0推出的新变量,记录历史命令的执行时间
譬如:HISTTIMEFORMAT="[%F %T]"
执行history,显示:
490 [2008-07-16 15:12:23]HISTTIMEFORMAT="[%F %T]"
491 [2008-07-16 15:12:25]history
492 [2008-07-16 15:12:32]man date
2. date 命令和strftime 函数,扩展clock、hwclock
date命令:print or set the system date and time
strftime函数:awk调用了类型为time_t的c函数库 strftime([format [, timestamp]])
功能:Formats timestamp according to the specification in format.
systime函数:同上,Returns the current time of day as the number of seconds since the Epoch systime()
譬如:设置系统时间:date -s "12/29/2008 18:00:00"
display系统时间:date -d "+3 day" + "%F %T" date -d "-3 years" + "%F %T"
毫秒级时间戳->格式化时间:echo 12879350 | awk '{print strftime("%F %T", $0)}'
格 式化时间->毫秒级时间戳:date -s把当前时间设置成special time,然后 awk '{print systime()}'即可 如:echo "05/05/2008" |awk '{print systime()}'
3.扩展的正则表达式- extended expression
包括: () | + ? 譬如:(a|b|c)+d?
R Running or runnable (on run queue) 运行中
S Interruptible sleep (waiting for an event to complete) 可打断的后台进程,类似守护进程httpd、ntpd、crond等
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its parent.
For BSD formats and when the stat keyword is used, additional characters may be displayed:
< high-priority (not nice to other users) 高优先级
N low-priority (nice to other users) 低优先级
L has pages locked into memory (for real-time and custom IO)
s is a session leader 主进程
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) 表示线程
+ is in the foreground process group 前台运行
5. su和login shell