Created
March 4, 2019 12:55
-
-
Save garenyondem/dbd1c25c3e247feac2295a74e528601e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get ids of processes running longer than 6 hrs (21600 secs) | |
PIDS=$(ps eaxo etimes,bsdtime,pid,comm,cmd | grep node | grep command-line-processes | awk '{if ($1 >= 21600) print $3}') | |
for i in ${PIDS}; | |
do { | |
PROC_FILE_PATH=$(ps eaxo pid,cmd | grep node | grep "$i"| awk '{print $3}'); | |
SCRIPT_NAME=$(basename "$PROC_FILE_PATH"); | |
printf "Killing $SCRIPT_NAME\n"; | |
kill $i; | |
}; | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment