æ¦è¦
- Shell Scriptå®è¡æã«å¦çæéãè¨æ¸¬ãããå ´åã®æ¹æ³ã«ã¤ãã¦è¨è¼ãã¾ã
ç°å¢
- OracleLinux 9.1
æéã®è¨æ¸¬ãå¯è½ãªã³ãã³ã
timeã³ãã³ã
- ã³ãã³ãã®å®è¡æéãè¨æ¸¬ããããã®ã³ãã³ãã§ã
time ã³ãã³ã
-
è¨æ¸¬ããæéã¯ä¸è¨ã®3種é¡ã¨ãªãã¾ãã
- real ã³ãã³ãã®å®è¡æé
- user ã¦ã¼ã¶CPUæé
- sys ã·ã¹ãã CPUæé
-
å®éã«
time
ã³ãã³ããå©ç¨ãã¦sleep
ã³ãã³ããå®è¡ããçµæ
$ time sleep 3 real 0m3.002s user 0m0.001s sys 0m0.000s
dateã³ãã³ã
- æå®ãããã©ã¼ãããã«å¿ããæéã表示ããããã®ã³ãã³ãã§ã
date ãªãã·ã§ã³ ã³ãã³ã
- å®éã«
date
ã³ãã³ããå®è¡ããçµæ
$ date "+%Y-%m-%d" 2024-07-18
Shell Scriptã®å®è¡æéãå®éã«è¨ã£ã¦ã¿ã
- Shell Scriptå
¨ä½ã®å®è¡æéãè¨ãå ´åã¯
date
ã³ãã³ã - ã³ãã³ãåä½ã®å®è¡æéãè¨ãå ´åã¯
time
ã³ãã³ããå©ç¨
#!/bin/bash # å¦çéå§æéãåå¾ start_time=`date "+%S"` # 1åç®ã®å¦ç echo 1åç®ã®å¦çéå§ time sleep 1 echo 1åç®ã®å¦ççµäº # 2åç®ã®å¦ç echo 2åç®ã®å¦çéå§ time sleep 2 echo 2åç®ã®å¦ççµäº # 3åç®ã®å¦ç echo 3åç®ã®å¦çéå§ time sleep 3 echo 3åç®ã®å¦ççµäº # å¦ççµäºæéãåå¾ end_time=`date "+%S"` # ã¹ã¯ãªããã®å®è¡æéã表示 total_time=$((end_time - start_time)) echo "å®è¡æé: $total_timeç§"