We have following script (in CentoS 6) in our lab to execute our applications with its output one-by-one.cd A/sleep 1gnome-terminal -t A --tab -e ./app1cd ../B/sleep 1gnome-terminal -t b --tab -e ./app2 sleep 2gnome-terminal -t c --tab -e ./app3This is working perfect.Now what we want is to generate core dump files for one of our application (i.e. app3)ulimit -c shows 0 by default, and I don't want to change its default value.  gnome-terminal -t c --tab -e ulimit -c unlimited ; ./c is not working, When googled found  that to run into a script it should be, sh -c ulimit -c unlimited. gnome-terminal -t c --tab -e sh -c ulimit -c unlimited is working perfect.But,gnome-terminal -t c --tab -e sh -c ulimit -c unlimited ; ./app3 is NOT working.How can I enable core dump for app3 only? NOTE: We don't want this globally.
How to run ulimit in a script with other application
shell script;gnome terminal;ulimit
There are three ways of doing this.Use a proper chain-loading command.Instead of using the shell built-in command ulimit, use commands that were developed for this purpose, from the various daemontools-family toolsets:softlimit from daemontoolssoftlimit from freedtsoftlimit from daemontools-encoresoftlimit from noshs6-softlimit from s6chpst from runitrunlimit from perpSo one would run, using softlimit from the nosh toolset as an example:gnome-terminal -t A --tab -e softlimit --coresize unlimited ./app1Use a subshell within the script.This applies the limit to the terminal emulator process as well.  In this case this will be fairly benign.  But if one is applying other limits such as open file handle limits or process forking limits this can be problematic.(ulimit -c unlimited ; urxvt -e ./app1)Note that this will not work with GNOME Terminal or the client-server variant of Unicode RXVT.  Both of those do not directly invoke the terminal emulator as a child of your script.  They perform a remote invocation via a server process, which will not have nor acquire the resource limits set in your script.Make GNOME Terminal run a shell that runs ulimit.Remember that you have to build this from the bottom upwards.You want the actual shell that does the work to run the command listulimit -c unlimited ; exec ./app1To pass this command list to sh it needs to be all one argument after -c, so needs to be quoted:sh -c ulimit -c unlimited ; exec \./app1\To pass the sh invocation to GNOME Terminal, that too needs to be all one argument after -e, so a second level of quoting needs to be applied:gnome-terminal -e 'sh -c ulimit -c unlimited ; exec \./app1\'