-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstop_exercise.sh
More file actions
executable file
·40 lines (32 loc) · 1.16 KB
/
stop_exercise.sh
File metadata and controls
executable file
·40 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Script para detener el ejercicio de Big Data
echo "🛑 Deteniendo ejercicio Big Data..."
# Buscar procesos relacionados
PROCESSES=$(ps aux | grep -E "(bigdata|producer|consumer)" | grep -v grep | grep python)
if [ -z "$PROCESSES" ]; then
echo "✅ No hay procesos del ejercicio ejecutándose"
else
echo "📋 Procesos encontrados:"
echo "$PROCESSES"
# Extraer PIDs y terminar procesos
PIDS=$(echo "$PROCESSES" | awk '{print $2}')
echo "🔄 Terminando procesos..."
for pid in $PIDS; do
kill $pid 2>/dev/null
echo " Terminado PID: $pid"
done
# Esperar un momento y verificar
sleep 2
REMAINING=$(ps aux | grep -E "(bigdata|producer|consumer)" | grep -v grep | grep python)
if [ -z "$REMAINING" ]; then
echo "✅ Todos los procesos terminados correctamente"
else
echo "⚠️ Algunos procesos siguen ejecutándose, forzando terminación..."
FORCE_PIDS=$(echo "$REMAINING" | awk '{print $2}')
for pid in $FORCE_PIDS; do
kill -9 $pid 2>/dev/null
echo " Forzado PID: $pid"
done
fi
fi
echo "🏁 Ejercicio detenido"