I launch my program from .sh file (for simplicity let's say it's content is just ./myprogram). For some unknown reason the program generates large core.* files. What should I add in my .sh file so that these files are being deleted while my program is running?
core files are written for post mortem of crashed processes, you must find out what is happening (a segmentation fault or other crash might signal a serious security vulnerability!).
As the file is written after the program crashed, they can safely be removed at any time. In any case, if you delete a file that is being held open by a process, the filesystem entry will be removed, but the process isn't affected at all.