代码之家  ›  专栏  ›  技术社区  ›  Bad_Coder

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

  •  1
  • Bad_Coder  · 技术社区  · 9 年前

    我正在努力找到一个命令,甚至是一种方法来找到我的 Solaris (sun4u sparc SUNW,Netra-T12)箱

    Solaris

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

    与相同 last reboot | head -n 1

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

    Linux系统

    谁-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 回复  |  直到 4 年前
        1
  •  1
  •   jlliagre    9 年前

    下面是一种在Solaris 10上使用 ksh bash :

    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)"