#!/bin/bash start=$(date +%s) # 1528437613 ping -c 10 baidu.com &> /dev/null end=$(date +%s) difference=$(( end - start )) echo $difference seconds.
运行后会输出脚本的运行时间
[root@localhost ~]# bash test.sh 10 seconds.
#!/bin/bash start=$(date +%s) # 1528437613 ping -c 10 baidu.com &> /dev/null end=$(date +%s) difference=$(( end - start )) echo $difference seconds.
运行后会输出脚本的运行时间
[root@localhost ~]# bash test.sh 10 seconds.