Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- #Author:jMa
- #
- #Description: Ejecuta los procesos pasados como parĂ¡metro en segundo plano y espera a que termine uno
- #para ejecutar otro.
- #
- #Sintax: ./encolapro -t tiempo [proceso1] ...[procesoN]
- # ./encolapro [proceso1] ...[procesoN] (En este caso se toman 60 segundos de tiempo)
- #
- echo $2 | grep -x -q "[0-9]\+"
- num=$?
- function process {
- $1 2> /dev/null &
- pid=$!
- while [ `ps aux | tr -s " " | cut -d " " -f 2| grep $pid | wc -l` -gt 0 ]
- do
- sleep $tiempo
- done
- }
- if [ \( "$1" == "-t" \) ] && [ \( "$num" == 0 \) ]
- then
- tiempo=$2
- shift
- shift
- while true
- do
- if [ "$1" = "" ]
- then
- break
- fi
- process $1
- shift
- done
- else
- tiempo=60
- while true
- do
- if [ "$1" = "" ]
- then
- break
- fi
- process $1
- shift
- done
- fi
Advertisement
Add Comment
Please, Sign In to add comment