myapp is an application that crashes eventually. I would like to get the core dump of those crashes...

This is the upstart script I have written to achieve this. It doesn't work yet.

description "myupstart"

start on runlevel [2534]
stop on runlevel [!2534]


    ulimit -c 10000
    echo "/var/crash/core.%e.%s.%u.%g.%p.%t" > /proc/sys/kernel/core_pattern

    cd /path/to/app

end script


myapp works with drop of permissions. It starts as root [of course] and then switches to another username/group. Is this a problem?

The following commands work on command line if I start the application manually, but they don't work in the upstart script:

ulimit -c 10000
echo "/var/crash/core.%e.%s.%u.%g.%p.%t" > /proc/sys/kernel/core_pattern

Why this difference?

  • The bounty says "The current answer(s) are out-of-date" but actually they are no answers! – Lucio May 30 '14 at 1:26
  • can I edit? I thought it was for answers of similar questions... that don't satisfy anymore... – Wagner Patriota May 30 '14 at 1:27
  • No, it is ok. If you think there are similar answers that didn't worked for you, you should mention them in the question. – Lucio May 30 '14 at 1:28

Try making a separate wrapper bash script with the commands between script and end script and pass that to an exec option in the same upstart file.

Chance are that whatever ulimit -c 10000 does disappears by the time upstart calls ./myapp.

Also note that it isn't quite correct to name your file "upstart script". It is a configuration file. It may happen to contain executable lines but its main purpose is to store configuration and not executable commands.

Addendum: I followd the same logic above, but instead of create another script, I had the idea of do ulimit -c 10000 && ./myapp and it worked! upstart accepted the &&

  • hummm... good idea... so I will try ulimit -c 10000 && ./myapp so I don't need to create another file... but the logic is the same! thanks – Wagner Patriota May 30 '14 at 1:30
  • I don't think upstart supports joining commands with &&, it may just pass the && as another parameter to ulimit. Remember, the upstart file is processed by upstart and not by bash (or another shell) and anything beyond program name and parameters is unlikely to work. – sмurf May 30 '14 at 1:37
  • "the upstart file is processed by upstart and not by bash" = COOL! but it accepted the && and it worked! thanks! :-) – Wagner Patriota May 30 '14 at 1:58

The following should work equally well.

description "myupstart"

start on runlevel [2534]
stop on runlevel [!2534]

limit core 10000 10000
chdir /path/to/myapp

pre-start script
    echo "/var/crash/core.%e.%s.%u.%g.%p.%t" > /proc/sys/kernel/core_pattern
end script

exec /path/to/app/myapp

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.