Skip to main content

Linux scripts

Monitor Running process

Detect running process

lists the process running on the server ps -eo command
IFS - Internal field seperater (is an environmental variable)
create a code to detect new process running and save the file as procmon.sh

#!/bin/bash

# Loop by line
IFS=$'\n'

old_process=$(ps -eo command)

while true; do
new_process=$(ps -eo command)
diff <(echo "$old_process") <(echo "$new_process")
sleep 1
old_process=$new_process
done