码迷,mamicode.com
首页 > 系统相关 > 详细

shell多进程脚本

时间:2017-11-27 19:57:36      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:ash   ++   shell   for   i++   grep   not   count   python   

#!/bin/bash

python_path=/home/huaw/crawler
python_name=list_all_v6_crawler.py
MAX_SYNC_PROCESS=40
echo "max allowed ic_stat_company_submit process is $MAX_SYNC_PROCESS"
current_sync_num=`ps -ef|grep $python_name | wc -l |grep -v grep`
current_sync_num=$[current_sync_num-1]
echo "current started ic_stat_company_submit process count $current_sync_num"
if [ $current_sync_num -lt $MAX_SYNC_PROCESS ]
then
sync_num=$[ MAX_SYNC_PROCESS-current_sync_num]
echo "not reach max processes,will start $sync_num process..."
for((i=1;i<=$sync_num;i++));do
echo "process will be started..."
cd $python_path
python $python_name >> list.log 2>&1 & 
done
else
echo "runing....."
fi

 

shell多进程脚本

标签:ash   ++   shell   for   i++   grep   not   count   python   

原文地址:http://www.cnblogs.com/themost/p/7905475.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!