How can I still get my core dump when I run something from cron which would normally core? How can I still get my core dump when I run something from cron which would normally core? unix unix

How can I still get my core dump when I run something from cron which would normally core?


For a core file to be generated on a crash, core dumps must be enabled in the current environment. From a shell, this can be done using ulimit:

ulimit -c unlimited

Which means "set the maximum core dump size to unlimited". Your system is probably configured to do this in interactive shells, but not in cron jobs. To do it from a cron job, you need to modify this limit. If the cron job is a shell script which calls other programs, you can just call ulimit as above. On the other hand, if the job is an executable, you can create a wrapper to run it with:

#!/bin/bashulimit -c unlimitedexec "$@"

Another option is to modify the program to set the limit itself using the setrlimit function.

As to why your cores are going in /cores as opposed to the working directory: your distribution may have adjusted the core pattern, possibly using a program to handle core files and place them in /cores.