2

Hi our server has a weird issue where once a month or so a GS (GhostScript) process gets stuck and eats 10-75% CPU until I kill the process. strace hasn't provided anything useful so until I can resolve this correctly I'd like to create a script that checks every few minutes and kills any GS process that has been running for longer than 5 minutes. Under normal circumstances this process should complete in a few seconds to a minute at most.

In top the command shows up as "GS". How do I go about doing this? I'm assuming I need to write a BASH script as well as set it to run on an interval? The box is a webserver running CentOS 6.5.

Thanks!

Jonathan
  • 207
  • 6
  • 10

1 Answers1

2

Use killall command as follow, Replace Process_Name with the GS process name,

killall  --older-than 5m Process_Name

To create a script file

touch myscript.sh

chmod +x myscript.sh

echo "killall  --older-than 5m Process_Name" > myscript.sh

To run the script every 5 mins, Assuming myscript is located in the root directory.

echo "*/5 * * * * /root/myscript.sh" >> /etc/crontab
MohyedeenN
  • 1,111