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

时间:2015-03-17 16:11:24

标签: solaris uptime

我正在努力寻找命令,甚至在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

1 个答案:

答案 0 :(得分:1)

这是一种在{10} kshbash下在Solaris 10上获取启动时间的hackish方式:

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

请注意,您需要是root用户才能在Solaris 10上运行它,而不是在Solaris 11上运行它。


修改: 这是一种更简单的方法,不需要root权限:

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