简易计算任务的探针.md 2.2 KB


title: 简易计算任务的探针 tags: [] id: '2237' categories:

  • - 未分类 date: 2022-08-13 05:47:10 ---

某些项目动辄跑上十天半个月,有时候需要在手机上简单了解该任务的运行状态,不想花里胡哨,这里写个sh脚本定时通知一下任务运行状态吧。发送通知的脚本看这里

简单的资源探针

#!/bin/bash
info="python3 /home/jovyan/upload/zl_liu/wecomchan.py"
interval=3600
 
pid=$1
echo $pid
 
topinfo=`top -d 2 -n 1  grep $pid`
freeMem='服务器空闲内存:'`free -g  grep "Mem"   awk '{print $7}'`'G'
topinfo=`echo $topinfo awk -F' ' '{print "VIRT:"$6," RES:"$7," CPU:"$10"%"," MEM:"$11"%"," RT:"$12}'`
minfo=`echo -e "${freeMem}\n进程信息:${topinfo}"`
echo $minfo
$info "$minfo"
while sleep $interval
do
 topinfo=`top -d 2 -n 1  grep $pid`
 if [ -z "$topinfo" ]; then
   echo "process is not running! will stop!"
   break;
 fi
 freeMem='服务器空闲内存:'`free -g  grep "Mem"   awk '{print $7}'`'G'
 topinfo=`echo $topinfo awk -F' ' '{print "VIRT:"$6," RES:"$7," CPU:"$10"%"," MEM:"$11"%"," RT:"$12}'`
 minfo=`echo -e "${freeMem}\n进程信息:${topinfo}"`
 echo $minfo
 $info "$minfo"
done

简单的计算探针

system(paste("python3 /home/jovyan/upload/zl_liu/wecomchan.py", "'fastMNN_task start'"), intern = T)
out  <-  tryCatch({
      #正常的逻辑
    do.call(fastMNN, c(original, list(k = 20, d = 50, BPPARAM = BiocParallel::MulticoreParam(6))));
  }, warning = function(w) {
      #出现warning的处理逻辑
    w <- as.character(w)
    w <- gsub("[\r\n']", "", w)
    system(paste("python3 /home/jovyan/upload/zl_liu/wecomchan.py", paste0("'",w,"'")), intern = T)
    w
  }, error = function(e) {
      #出现error的处理逻辑
    e <- as.character(e)
    e <- gsub("[\r\n']", "", e)
    system(paste("python3 /home/jovyan/upload/zl_liu/wecomchan.py", paste0("'",e,"'")), intern = T)
    e
  }, finally = {
      #不管出现异常还是正常都会执行的代码模块,
      #一般用来处理清理操作,例如关闭连接资源等。
})
system(paste("python3 /home/jovyan/upload/zl_liu/wecomchan.py", "'fastMNN completed'"), intern = T)