#!/bin/sh
export SGE_ROOT=/opt/sge
source /opt/sge/default/common/settings.sh
#Current time with converting to seconds
c_time=`date +"m:%d:%y"`
C_time=`echo "$c_time" | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }'`
qstat -u "*" | grep "sim" | grep " r " > qstatfile
while read line
do
#Job start time
S_time=`echo "$line" | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }'`
#Get Diff time b/w start and current time
DIFFSEC=`expr ${S_time} - ${C_time}`
#More than 3 hours
if [ "$DIFFSEC" -gt 10800 ];
then
U_name=`echo "$line" | awk ' { print $4 } '`
job_id=`echo "$line" | awk ' { print $1 } '`
echo -e "Hi $U_name,\n Your job ID $job_id is running more than 3 hours.\n--->Click below link to keepalive \n http://vncin14/cgi-bin/action.sh?jobid=$job_id&action=keep-alive\n--->To kill this job ID $job_id click below link\n http://vncin14/cgi-bin/action.sh?jobid=$job_id&action=kill-job" | mail -s "Job Keep alive or kill"
vidyasagar@xyz.com
fi
done < qstatfile
CGI script
#!/bin/bash
echo "Content-type: text/html"
echo ""
JOBID=`echo "$QUERY_STRING" | sed -n 's/^.*jobid=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
ACTION=`echo "$QUERY_STRING" | sed -n 's/^.*action=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
echo "<html><head><title>What You Said</title></head>"
echo "<body>Here's what you said:"
echo "You entered $JOBID for job ID and wanted the action to be $ACTION."
echo "</body>"
echo "</html>"
Now when user select kill option i want to send qdel $job_id signal through script where to put this command qdel $job_id