-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.bash
More file actions
executable file
·33 lines (32 loc) · 1.12 KB
/
menu.bash
File metadata and controls
executable file
·33 lines (32 loc) · 1.12 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
#!/bin/bash
while true
do
echo -e "\nMonitoraggio server. Comandi disponibili:\n 1) Inizia monitoraggio\n 2) Ferma monitoraggio\n 3) Stampa info utilizzo\n 4) Chiudi\n 5) checkSpace"
read -p "Inserisci numero comando[1-5]: " input
echo -e "\n"
case $input in
1) # Prima controllo che il processo non sia già in esecuzione
if [ "$(ps -ef | grep recorder.bash | grep -v grep)" ]; then
echo "Monitoraggio server già in esecuzione"
else
# Eseguo in background lo script recorder.bash
bash recorder.bash &
echo "Monitoraggio server avviato"
fi
;;
2) # Prima controllo che il processo sia già in esecuzione
if [ "$(ps -ef | grep recorder.bash | grep -v grep)" ]; then
pid=$(ps -ef | grep recorder.bash | grep -v grep | tr -s ' ' | cut -d ' ' -f2)
# SIGPIPE lo uso per non stampare a video il messaggio di terminazione del processo
kill -SIGPIPE $pid
echo "Monitoraggio server fermato"
else
echo "Nessun monitoraggio server in esecuzione"
fi
;;
3) bash query.bash;;
4) exit 0;;
5) bash checkSpace.bash;;
*) echo -e "Comando inserito non corretto!\n";;
esac
done