File: //proc/1284358/cwd/bigscoots/cpanel/rsync_check.sh
#!/bin/bash
# Get the process IDs of rsync processes
rsync_pids=$(ps aux | grep rsync | grep -v grep | awk '{print $2}')
# Current timestamp
current_time=$(date +%s)
# Duration threshold in seconds (12 hours = 12 * 60 * 60 seconds)
threshold=$((12 * 60 * 60))
# Iterate over each rsync process ID
for pid in $rsync_pids; do
# Get the start time of the process in seconds since epoch
start_time=$(ps -o lstart= -p $pid --no-headers | xargs -I {} date -d '{}' +%s)
# Calculate the duration in seconds
duration=$((current_time - start_time))
# Check if the duration exceeds the threshold
if ((duration > threshold)); then
#echo "Rsync process with PID $pid has been running for more than 12 hours."
# You can perform any additional actions here, such as terminating the process
kill $pid
fi
done