Red Hat Bugzilla – Bug 134093
Java Application crashes when run from cron
Last modified: 2007-11-30 17:07:04 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.3)
Description of problem:
I've coded a small hello world application which runs fine at the
command line but crashes immediately when being run by cron.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Add attached java program via
x y * * * /etc/alternatives/jre_ibm/bin/java TestMe >/home/digf/x.out
to the crontab of a normal user (set x and y as needed)
2. Wait for the cron job to be executed
Actual Results: Job gets started but hangs. No output is generated.
Expected Results: Job executes and output is created
digf 17946 17945 0 18:09 ? 00:00:00 /bin/sh -c
/etc/alternatives/jre_ibm/bin/java TestMe >/home/digf/x.out 2>x.err
digf 17949 17946 0 18:09 ? 00:00:00 [java.bin <defunct>]
When prepending LD_ASSUME_KERNEL=2.4.1 before the command, everything
works as expected; as it does when called directly from the command
line; LD_ASSUME_KERNEL is NOT being set at the command line or
environement. It also works from cron on i686 machines but not on a
Created attachment 104516 [details]
Source file with sample program
This may be caused by the stack limit workaround in the java wrapper
script. Open /etc/alternatives/jre_ibm/bin/java with a text editor
and try commenting out the if clause.
I've tried calling
* /usr/lib/jvm/java-1.4.2-ibm-ibm-126.96.36.199/jre/bin/java.bin directly
* commented everything but the ulimit -s 10240 and called the shell
Again nothing happend (and I've got a defunct process).
Can you run "env" on the command line and as a cron job and post the
results? Likewise for "ulimit -a"?
There may be relevant environment variables that are set on the
command line but not by cron. Likewise, resource settings may differ
in each case.
Another (less likely) possibility is that this is a permission
problem; does the cron job work when run from the root account?
Created attachment 105190 [details]
env from command line
Created attachment 105191 [details]
env from cron
Created attachment 105192 [details]
ulimit from command line
Created attachment 105193 [details]
ulimit from cron
I've created the requested outputs and added them via attachements to
the bug. Running the program from cron as root didn't work, too.
What still confuses me, is, why prepending LD_ASSUME_KERNEL=2.4.1 helps?
LD_ASSUME_KERNEL=2.4.1 causes the dynamic linker to load the
LinuxThreads thread library instead of the default, NPTL. It appears
that the JVM happens to work with LinuxThreads but not with NPTL.
The only difference in the ulimits is the max user processes value.
You may want to try setting that limit in the cron job to the command
From the environment variables in the output you've posted, I would
guess that only NLS_LANG, USER, MAIL, LANG and DISPLAY may be
relevant. Try setting them for the cron run.
Hopefully IBM will release a native x86-64 JVM soon, which will likely
solve this problem without requiring any of these workarounds.
IBM has released a native x86-64 JVM that will ship with RHEL3-U4 as
Just brought the machine to U4 and installed the new java rpms.
Everything is now working as expected. So this bug can be closed from
my point of view. Thanks!