I really suggest finding the root cause of this issue (or this issue or this issue).
A killall
is a heavy-handed approach to process management, and your real issue is probably an application or resource problem.
Can you outline what you've tried so far? The types of things I would check are:
- System vitals at the time these runaway Ghostscript processes occur: RAM? CPU?
- Make sure the system this is running on has enough memory and doesn't have major contention for other resources.
- Is this a physical or virtual server?
- Talk to the vendor. There's a community and some level of support around PrinceXML.
- A possible
strace
of the affected PIDs and Parent PIDs.
- Are all of the requisite fonts installed?
- Try logging the times that this happens to see if there's a correlation between the hang and other system events.
- If you don't have historical and granular monitoring, you should. You could even try something like NewRelic to try to get a picture of what is happening or happened at a given time.
- Check apache settings. It looks as though Ghostscript is being spawned by the apache user. Are there any limits or server settings that should be examined here?
Based on your output from an earlier question, it looks like you've only allocated 1 Gigabyte of RAM to this system and possibly only have a single CPU - no swap either...
If all else fails, you can write a script that can clean up old or stalled processes... or just compile a version of killall
that supports the --older-than
flag.