How can I get daemons started by init.d at boot to coredump on Ubuntu? This is what I have done so far...

echo "ulimit -c unlimited" >> /etc/profile
mkdir /corefiles/
chmod 777 /corefiles/
echo "kernel.core_pattern=/corefiles/core.%e.%u.%t" >> /etc/sysctl.conf
echo "fs.suid_dumpable=1" >> /etc/sysctl.conf
echo "kernel.core_uses_pid = 1" >> /etc/sysctl.conf
sysctl -p

This works great for everything except a daemon that is started by init.d at boot. I am running Ubuntu 10.04. I am looking for a solution that does not involve editing each daemons init.d file.

EDIT: Also, daemons started with sudo do not coredump.


Why not use Apport? It's disabled by default on non-development versions of Ubuntu, but it's still installed by default AFAIK.

  • Apport looks like it would be quite useful. Can it be used without X.org/gnome, just with a cli? – user16517 Aug 25 '10 at 14:18
  • Yes, no problem. On a crash it will collect some info, including a crashdump, a backtrace, etc. and pack that in a *.crash file in /var/crash/. When you have a GUI, update-manager will monitor that directory and ask if you want to submit a bug, but without a GUI you can use some tools. If you only want the coredump, you can unpack the *.crash file with apport-unpack. – JanC Aug 26 '10 at 6:30
  • Thanks, I reverted what I set originally and enabled apport. Now all crashes are recorded and saved in /var/crash. – user16517 Aug 26 '10 at 13:57

/etc/profile is executed when a user logs in for an interactive session (and even then that depends on the login method and login shell). It has no effect on daemons started at boot.

Apparently (I haven't tested to confirm) core dumps start out disabled on Ubuntu 10.04. They can be enabled by setting a nonzero size limit in /etc/security/limits.conf. See the comments in that file and the limits.conf man page for more information. I think you'll want to add a line like

*  soft  core  2000000

Programs that have elevated privileges generally don't dump core (I don't know the exact rule off the top of my head). This may affect processes launched directly through privilege elevation such as sudo foo; try sudo sh -c foo instead (so that the child process starts at its final privilege level).


/etc/profile is only sourced by your login shell, not by initscripts.

/etc/security/limits.conf will also only affect login sessions as well, as those limits are put in place by pam_limits.so; from pam_limits manpage:

The pam_limits PAM module sets limits on the system resources that can be obtained in a user-session.

To get the behaviour you want, you should modify the initscript and insert your ulimit -c unlimited command. As Dom mentioned, you could also do this by editing the lsb init-functions library.


I think all of these options are need for the daemons you launch. To have the core dumps, you should add the ulimit command to the beginning of the launchers. The Launchers should use /lib/lsb/init-functions. So you may modify it as you want. I don't test anything here, so try !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.