用于计算并行作业完成时间的shell脚本

用于计算并行作业完成时间的shell脚本,shell,Shell,我有一个程序,其中两个进程并行运行,如下所示 #!/bin/bash nohup /bin/bash -s <<< "hive -f ./create.hql >&/dev/null" & pid_c=$! nohup /bin/bash -s <<< "hive -f ./load.hql >&/dev/null" & pid_l=$! wait $pid_c ex_pid_c=$? ##time1=$(ps -p

我有一个程序,其中两个进程并行运行,如下所示

#!/bin/bash
nohup /bin/bash -s <<< "hive -f ./create.hql >&/dev/null" &
pid_c=$!
nohup /bin/bash -s <<< "hive -f ./load.hql >&/dev/null" &
pid_l=$!
wait $pid_c
ex_pid_c=$?
##time1=$(ps -p "$pid_c" -o etime=) not working
if [ $ex_pid_c -eq 0 ]; then
echo "Job completed."
else
echo "Failed"
fi
wait $pid_l
ex_pid_l=$?
##time2=$(ps -p "$pid_l" -o etime=) not working
if [ $ex_pid_l -eq 0 ]; then
echo "Job completed."
else
echo "Failed"
fi
#/bin/bash

nohup/bin/bash-s您可以使用
time
命令来了解每一个文件所用的时间(结果转到
stderr
):

希望能有帮助

或者最简单的方法是调用shell,比如说
a.sh
,方法如下:

time ./a.sh
给予

nohup: appending output to `nohup.out'
nohup: appending output to `nohup.out'
Job completed.
Job completed.

real    0m10.01s
user    0m0.00s
sys     0m0.01s

您可以使用
time
命令来了解每一次所用的时间(结果转到
stderr
):

希望能有帮助

或者最简单的方法是调用shell,比如说
a.sh
,方法如下:

time ./a.sh
给予

nohup: appending output to `nohup.out'
nohup: appending output to `nohup.out'
Job completed.
Job completed.

real    0m10.01s
user    0m0.00s
sys     0m0.01s

您可以使用
time
命令。这非常有用:-


您可以使用
time
命令。这非常有用:-


我可能太挑剔了,但你想要测量,而不是计算。我可能太挑剔了,但你想要测量,而不是计算。
/usr/bin/time
也可以使用。我发现在不同的系统(达尔文、CentOS、Ubuntu、AIX等)上对同一进程进行计时时,这种方法很有用,shell实用程序
time
有时会以不同的格式输出。
/usr/bin/time
。我发现在不同的系统(Darwin、CentOS、Ubuntu、AIX等)上对同一进程进行计时时,这很有用,因为shell实用程序
time
有时会以不同的格式输出。谢谢。但是如果我想将这些时间存储在脚本中的某个变量中,那么如何实现呢?谢谢。但是如果我想将这些时间存储在脚本中的某个变量中,那么如何实现呢?