# avoid core files



## cyrille (Apr 14, 2019)

Hy,
I'd like to avoid the creation of core dump files
I've read it's possible to do this with

```
limit coredumpsize 0
```
in /etc/csh.login

But I'd like to apply that on my user which use a bash shell .
Do you think that this option is correct ?

```
ulimit -c 0
```
in .bash_profile

Or is there a better way ?

Thanks !


----------



## George (Apr 14, 2019)

You could add `dumpdev="NO"` to your /etc/rc.conf file.


----------



## cyrille (Apr 14, 2019)

I already have this option but I still have core dump files

```
ls *.core
python3.6.core   soffice.bin.core VBoxSVC.core
```


```
cat /etc/rc.conf | grep dump
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"
```


----------



## acheron (Apr 14, 2019)

.core files
					

Is there someway to put the *.core file/s in /tmp for auto deletion which are application crash files. I have used FBSD before (version 8.0) but did not see .core files, in 8.1 I am getting .core files.




					forums.freebsd.org


----------



## ralphbsz (Apr 14, 2019)

Elazar said:


> You could add `dumpdev="NO"` to your /etc/rc.conf file.


That is for the dump that the OS creates when it crashes, not for the core files that individual programs create.

For stopping those, the limit (csh) or ulimit (sh) technique should work.  One of the things that makes that technique a bit difficult is that these commands need to be executed in the environment of the program itself.  For programs that are started from the shell command line, that's easy, since they run in the environment of the current shell.  But many interestingly complex programs are started in different ways, for example from rc if they are servers, via ssh or similar mechanisms for remote invocation, and sometimes from GUIs.  Those may be considered non-interactive programs as far as the shell is concerned.  You have to make sure whatever shell startup file (.cshrc, .profile, .bashrc, ...) you put the limit/ulimit command in will actually be executed, and you need to make sure the commands are not hidden behind if statements: Most of these startup files have a long section of settings that only apply to interactive commands.


----------



## cyrille (Apr 14, 2019)

OK thanks a lot for this very detailed explanation.


----------



## MarcoB (Apr 14, 2019)

You can prevent coredumps by putting `kern.coredump=0`, or reroute them by putting `kern.corefile=/dev/null` in /etc/sysctl.conf.


----------

