Tuesday, 24 February 2015

Gnome restart in linux + perl regex

grestart()
{
ps aux | grep -i session | grep -i ubuntu | grep Ssl | grep -v grep
echo "shall i kill [Y/y]"
read a
case $a in
'y'|'Y')
   perl ~/gnome-killer;;   
'n'|'N')
   echo "Ok ";;
*)
  echo "Invalid Input";;
esac
}


cat ~/gnome-killer

@s=`ps aux`;
while($line=pop(@s))
    {
    if($line=~/[0-9]\:[0-9]{2}\s+gnome-session/)
        {
        @killme=split(/\s/,$line);
        system ("sudo kill -9 $killme[3]");
        }
    }

No comments:

Post a Comment