如何在 solaris 上获得完整的启动时间

how to get complete startup time on solaris

我正在努力寻找一个命令,甚至是在我的 Solaris(sun4u sparc SUNW,Netra-T12) 盒子上找到完整启动时间的方法

Solaris

who -b 给我 Jun 22 11:09 但没有年份

last reboot | head -n 1

但是在我的 Linux(GNU/Linux x86_64) 框中,我可以获得完整的启动时间

Linux

who -b 给我 2014-08-23 11:09

有什么帮助吗?

编辑

apptrace uptime 2>&1

的输出
-> uptime   -> libc.so.1:int atexit(int (*)() = 0xff3c59ec)
<- uptime   -> libc.so.1:atexit()
-> uptime   -> libc.so.1:int atexit(int (*)() = 0x10ae8)
<- uptime   -> libc.so.1:atexit()
-> uptime   -> libc.so.1:char * setlocale(int = 0x6, const char * = 0x10af8 "")
<- uptime   -> libc.so.1:setlocale() = 0xfefdb25e
-> uptime   -> libc.so.1:char * textdomain(const char * = 0x10afc "SUNW_OST_OSCMD")
<- uptime   -> libc.so.1:textdomain() = 0x22b58
-> uptime   -> libc.so.1:sysinfo(0x202, 0xffbff97f, 0x1) ** NR
-> uptime   -> libc.so.1:void * malloc(size_t = 0x73)
<- uptime   -> libc.so.1:malloc() = 0x23158
-> uptime   -> libc.so.1:sysinfo(0x202, 0x23158, 0x73) ** NR
-> uptime   -> libc.so.1:const char * getexecname(void)
<- uptime   -> libc.so.1:getexecname() = 0xffbfffc5
-> uptime   -> libc.so.1:strlen(0xffbfffc5, 0x23158, 0x10800) ** NR
-> uptime   -> libc.so.1:void * malloc(size_t = 0x82)
<- uptime   -> libc.so.1:malloc() = 0x231d8
-> uptime   -> libc.so.1:strcpy(0x231d8, 0xffbfffc5, 0xffbfffd4) ** NR
-> uptime   -> libc.so.1:char * strrchr(const char * = 0x231d8 "/usr/bin/uptime", int = 0x2f)
<- uptime   -> libc.so.1:strrchr() = 0x231e0
-> uptime   -> libc.so.1:strlen(0x231d8, 0x2f, 0x231eb) ** NR
-> uptime   -> libc.so.1:char * strtok(char * = 0x23158 "sparcv9+vis2 sparcv9+vis sparcv9 sparcv8plus+vis2 sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc", const char * = 0x10b60 " ")
<- uptime   -> libc.so.1:strtok() = 0x23158
-> uptime   -> libc.so.1:strcpy(0x231e1, 0x23158, 0x231e1) ** NR
-> uptime   -> libc.so.1:char * strcat(char * = 0x231e1 "sparcv9+vis2", const char * = 0x10b64 "/")
<- uptime   -> libc.so.1:strcat() = 0x231e1
-> uptime   -> libc.so.1:char * strcat(char * = 0x231e1 "sparcv9+vis2/", const char * = 0xffbfffce "uptime")
<- uptime   -> libc.so.1:strcat() = 0x231e1
-> uptime   -> libc.so.1:access(0x231d8, 0x1, 0x231f1) ** NR
-> uptime   -> libc.so.1:char * strtok(char * = 0x0 <NULL>, const char * = 0x10b84 " ")
<- uptime   -> libc.so.1:strtok() = 0x23165
-> uptime   -> libc.so.1:strcpy(0x231e1, 0x23165, 0x231f1) ** NR
-> uptime   -> libc.so.1:char * strcat(char * = 0x231e1 "sparcv9+vis", const char * = 0x10b64 "/")
<- uptime   -> libc.so.1:strcat() = 0x231e1
-> uptime   -> libc.so.1:char * strcat(char * = 0x231e1 "sparcv9+vis/", const char * = 0xffbfffce "uptime")
<- uptime   -> libc.so.1:strcat() = 0x231e1
-> uptime   -> libc.so.1:access(0x231d8, 0x1, 0x231f0) ** NR
-> uptime   -> libc.so.1:char * strtok(char * = 0x0 <NULL>, const char * = 0x10b84 " ")
<- uptime   -> libc.so.1:strtok() = 0x23171
-> uptime   -> libc.so.1:strcpy(0x231e1, 0x23171, 0x231f0) ** NR
-> uptime   -> libc.so.1:char * strcat(char * = 0x231e1 "sparcv9", const char * = 0x10b64 "/")
<- uptime   -> libc.so.1:strcat() = 0x231e1
-> uptime   -> libc.so.1:char * strcat(char * = 0x231e1 "sparcv9/", const char * = 0xffbfffce "uptime")
<- uptime   -> libc.so.1:strcat() = 0x231e1
-> uptime   -> libc.so.1:access(0x231d8, 0x1, 0x231ec) ** NR
-> uptime   -> libc.so.1:execve(0x231d8, 0xffbff9e4, 0xffbff9ec) ** NR
ld.so.1: uptime: warning: /usr/lib/abi/sparcv9/apptrace.so.1: open failed: illegal insecure pathname
ld.so.1: uptime: warning: /usr/lib/abi/sparcv9/apptrace.so.1: audit initialization failure: disabled
  3:26pm  up 270 day(s), 13:42,  2 users,  load average: 2.08, 2.07, 2.07

这是在 kshbash 下获取 Solaris 10 启动时间的 hackish 方法:

perl -le "print scalar localtime hex(\"$(apptrace -v getutxent uptime 2>&1 | nawk '
/ut_type:/ {if(=="0x2"){boot=1}}
boot == 1 && [=10=] ~ ".*tv_sec:.*" {sub("0x","",);print ;exit}')\")"

请注意,您需要在 Solaris 10 上成为 运行 它的 root,但在 Solaris 11 上则不需要。


编辑: 这是一个不需要root权限的更简单的方法:

perl -le "print scalar localtime $(kstat -pn system_misc -s boot_time|cut -f 2)"