Skip to content
Advertisement

How can I make a ksh script terminate itself if any issues?

I have written a few ksh scripts, about 6 scripts. These are written to handle huge data files, something like 207 MB big. while running the script, sometimes it gets stuck and does not end. Human interruption is required. In production environment, I want it to run automatically, and should be able to end automatically if any issues without the need of any human interruption. If there are some issues with a file, the script should end and start executing the next file. How can make it terminate itself, if it gets stuck?

Advertisement

Answer

I assume, that the only way you see the issues is that the script takes too long. In that case a simple script that kills the process after a time-out should be sufficient:

JavaScript

Your workflow would then be something like:

JavaScript

If you have other ways to detect issues in your processes, you can easily add them to the loop in your killerscript.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement