操作筆記:Linux查看系統時間

來源:互聯網
上載者:User

前一段時間微軟推出了Windows 7作業系統,掩蓋了Linux的光芒,不過Linux還是受到廣大使用者的喜愛。我們在學習中會遇到很多問題,比如Linux查看系統時間,本文為你講解Linux查看系統時間。

1.uptime命令
輸出:16:11:40 up 59 days, 4:21, 2 users, load average: 0.00, 0.01, 0.00

2.查看/proc/uptime檔案計算系統啟動時間
cat /proc/uptime
輸出: 5113396.94 575949.85
第一數字即是系統已啟動並執行時間5113396.94 秒,運用系統工具date即可算出系統啟動時間

代碼:
date -d "$(awk -F. '{print $1}' /proc/uptime) second ago" +"%Y-%m-%d %H:%M:%S"

輸出: 2008-11-09 11:50:31

3.查看/proc/uptime檔案計算系統已耗用時間

代碼: 
cat /proc/uptime| awk -F. '{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("系統已運行:%d天%d時%d分%d秒",run_days,run_hour,run_minute,run_second)}'

輸出:系統已運行:59天4時13分9秒

這樣你就能輕鬆地應用Linux查看系統時間。

  1. Linux Opera輕鬆應用scim
  2. 簡單的Linux使用者口令
  3. 教會你Linux擷取檔案大小方法
  4. 輕鬆完成Linux安裝Flash Media Server
  5. 闡述Linux系統時鐘同步服務NTPD配置技巧

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.