Optimize script logs

pull/2007/head^2
skiffer-git 2 years ago
parent 14bce90f14
commit 422c01870a

@ -409,17 +409,19 @@ for process_name in "$@"; do
# Check if any process IDs were found # Check if any process IDs were found
if [[ ${#pids[@]} -eq 0 ]]; then if [[ ${#pids[@]} -eq 0 ]]; then
not_started+=($process_name) not_started+=("$process_name")
else else
# If there are PIDs, loop through each one # If there are PIDs, loop through each one
for pid in "${pids[@]}"; do for pid in "${pids[@]}"; do
local command=$(ps -p $pid -o cmd=) local command=$(ps -p $pid -o cmd=)
local start_time=$(ps -p $pid -o lstart=) local start_time=$(ps -p $pid -o lstart=)
local port=$(get_port $pid | tr -d '\n') # Use `tr` to remove newline characters local port=$(get_port $pid | tr -d '\n') # Remove newline characters
# Check if port information was found for the PID # Ensure port information is followed by a space for separation
if [[ -z $port ]]; then if [[ -z $port ]]; then
port="N/A" port="N/A "
else
port="$port " # Add a trailing space for separation
fi fi
started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time") started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time")

Loading…
Cancel
Save