linux脚本查看当前系统已经运行的时间

脚本如下: 

#!bin/bash
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)}'

保存文件为time.sh

终端输入: 

sh ./time.sh

运行结果如下:

猜你喜欢

转载自blog.csdn.net/qq_26018075/article/details/104814242