#!/bin/bash

. /octopus-agent/shell/lib/wdd-lib-log.sh

start_time=$(date +%s)
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))


#if [[ $(ps -ef | grep -v "color" |grep -c "/octopus-agent/shell/function/load50cpu_2_hour") -gt 0 ]]; then
#    log "已经存在CPU占用进程 ！杀死该进程"
#    kill -9 $(ps -ef | grep -v "color" |grep "/octopus-agent/shell/function/load50cpu_2_hour" | awk '{print$2}')
#fi


log "开始执行CPU占用任务，占用时间为 2小时！"
while [ $elapsed_time -lt 7200 ]
do
  # Busy wait
  for i in {1..1000000}
  do
    :
  done
  current_time=$(date +%s)
  elapsed_time=$((current_time - start_time))
done

log "CPU占用任务完成！"
