linux脚本(3)——让程序跑完后时间参数+1继续运行
原创
©著作权归作者所有:来自51CTO博客作者wx59658a994b151的原创作品,请联系作者获取转载授权,否则将追究法律责任
测试完了,不建议使用
前言
在实际工作中,我们可能会遇到一些特定的需求,输出一定时间段的数据,如果手动提交,就要等程序跑完,修改参数继续提交,如此循环,那么怎么写一个脚本解放双手呢?
一、 思路
检测指定程序有几个在运行,当有一个在运行时候不做处理,当没有在运行的时候,时间参数加一,执行脚本
二、脚本代码
Checktest.sh
#!/bin/bash
exec_num=`ps -ef | grep TTest.test.Test01| grep -v grep |wc -l`
if test ${exec_num} -gt 1 ;then
exit
fi
start_time=$1
aa=$2
for (( i = ${1}; i < ${2}; i++ )); do
sh /home/rx_yzj/bash/test.sh ${1}
done
test.sh
nohup spark-submit --master yarn --deploy-mode cluster \
--queue test \
--driver-memory 4g --executor-memory 40g --num-executors 6 --executor-cores 10 \
--files "./user.test.keytab" \
--conf spark.port.maxRetries=128 \
--conf spark.executor.memoryOverhead=4096 \
--conf spark.driver.memoryOverhead=1024 \
--conf spark.driver.maxResultSize=8g \
--conf spark.shuffle.service.index.cache.size=7196m \
--conf spark.network.timeout=600s \
--conf spark.reducer.maxSizeInFlight=144m \
--conf spark.executor.heartbeatInterval=60s \
--conf spark.shuffle.file.buffer=3m \
--conf spark.shuffle.io.maxRetries=6 \
--conf spark.shuffle.sort.bypassMergeThreshold=400 \
--conf spark.memory.offHeap.enabled=true \
--conf spark.memory.offHeap.size=4096 \
--conf spark.shuffle.unsafe.file.output.buffer=300m \
--conf spark.unsafe.sorter.spill.reader.buffer.size=300m \
--conf spark.default.parallelism=120 \
--conf "spark.executor.extraJavaOptions=-XX:ParallelGCThreads=5 -XX:+UseParallelGC -XX:+UseAdaptiveSizePolicy -XX:NewRatio=4" \
--class TTest.test.Test01 \
/home/rx_yzj/jars/test.jar \
$1\
> /home/rx_yzj/logs/test 2>&1 &
设置定时任务,此处设置程序从4号跑到6号
*/1 * * * * /bin/bash /home/rx_yzj/bash/Checktest.sh 20220804 20220806