Bash – Launch new terminals

A simple example to launch terminals (gnome-terminal) with bash. This example launches 4 terminals; each monitoring the system in a different way.

#!/bin/bash
# [Eaxample] Helper script to launch CLI apps
# Created to use gnome-terminal (e.g. instead of pterm, etc)

ROUTING_TABLE_CMD="watch -n 30 netstat -r"
DISK_USAGE_CMD="watch -n 60 df -h"
ACTIVE_PROCESSES_CMD="top -a"
MEMORY_UTILIZATION_CMD="watch -n 5 free -m"

echo "Starting netstat to monitor routing table."
gnome-terminal -t "ROUTING TABLE" -x bash -c "$ROUTING_TABLE_CMD" &

echo "Starting df to monitor disk usage."
gnome-terminal -t "DISK USAGE" -x bash -c "$DISK_USAGE_CMD" &

echo "Starting "top" to monitor active process."
gnome-terminal -t "ACTIVE PROCESSES" -x bash -c "$ACTIVE_PROCESSES_CMD" &

echo "Starting "free" to monitor memory utilization."
gnome-terminal -t "MEMORY UTILIZATION" -x bash -c "$MEMORY_UTILIZATION_CMD" &

 

Leave a Comment