Cron Throws "Exception in thread "main" No such file or directory"

Posted on 2004-11-26
Last Modified: 2013-12-15

I have scheduled a cron job to run at 8:00 o'clock every night without fail.  Here is the crontab:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (legacy.cron installed on Fri Nov 26 09:15:21 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
00 20 * * * /opt/myApp/

When the application is run directly (not through Cron) it works fine.  Its just a shell script that loads up a java application:


/opt/java/j2sdk/bin/java -Xbootclasspath/a:"/opt/myApp/resource.jar" -jar lib/myJar.jar -config myConfig.conf 2>&1 | tee /opt/myApp/logfile.log

However, when run through Cron, I receive the following error in the log file:

Exception in thread "main" No such file or directory
        at Method)
        at java.util.jar.JarFile.<init>(
        at java.util.jar.JarFile.<init>(

This is only when the app is run through Cron.  As far as I am aware, the application doesn't call any zip functions, but I am quite new to Java and I could be wrong.

Any help would be brilliant, thanks!
Question by:garry_m
    LVL 17

    Assisted Solution

    Its probably a path problem. After you have run it from the command line, run "set". One of the lines will show you your current path. Copy this line and insert the following in your after #!/bin/bash

    export PATH=line-copied-from-set-command
    LVL 38

    Accepted Solution

    >  the application is run directly (not through Cron) it works fine
    The environment variable setting issue. Cron doesn't have your environment variable setting to tun the application.
    Set the environment variables in /opt/myApp/
    or add ". <path to your home dir>/.bashrc" at the second line of /opt/myApp/


    Author Comment

    Thanks guys!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
    If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now