还是有漏洞 ,万一 working.py未超时, kill_job.sh 会不会杀死别人的进程啊
start.sh#!/bin/bash
python working.py &
python working.py &
python working.py &
pids=$(jobs -p)
echo $pids
sh kill_job.sh $pids &
pids_1=$(jobs -p)
echo $pids_1
for job in $pids
do
wait $job
done
kill $pids_1
echo 'complete'
kill_job.sh
#!/bin/bash
echo $1 $2 $3
echo 'sleep 5 min , then kill jobs'
sleep 300
kill $1
kill $2
kill $3
working.py
#!/usr/bin/env python
# --*-- coding:utf-8 --*--
import time
import datetime
while True:
print datetime.datetime.now()
print 'sleep 1000 s'
time.sleep(30)
print 'complete'