Python测试进阶——(7)动手编写Bash脚本启动Python监控程序并传递PID

如下:

  1 #./cf_workload_functions.sh
  2 
  3 function timestamp(){        # get current timestamp
  4     sec=`date +%s`
  5     nanosec=`date +%N`
  6     re='^[0-9]+$'
  7     if ! [[ $nanosec =~ $re ]] ; then
  8     $nanosec=0
  9     fi
 10     tmp=`expr $sec \* 1000 `
 11     msec=`expr $nanosec / 1000000 `
 12     echo `expr $tmp + $msec`
 13 }
 14 
 15 function start_monitor(){
 16     MONITOR_PID=`python monitor190620_1948.py`
 17     echo ${MONITOR_PID}
 18 }
 19 
 20 START_TIME=`timestamp`
 21 
 22 MONITOR_PID=`start_monitor`
 23 echo ${MONITOR_PID}
 24 
 25 END_TIME=`timestamp`
 26 
 27 echo "scale=3;(${END_TIME}-${START_TIME})/1000"
 28 

猜你喜欢

转载自www.cnblogs.com/ratels/p/11074785.html