#!/bin/bash
start=$(date +%s)
yum install httpd -y
end=$(date +%s)
different=$((end - start))
echo $different
echo time taken to execute commands is $difference seconds.
本例子是在测试安装http所需要的时间
如果要查看一个命令花费的时间也可以使用time
[root@iZ2ze20j4zsv1q8o9py23wZ ~]# time find . -name 'a.sh'
./a.sh
real 0m0.013s
user 0m0.