cron job: permission denied

Posted on 2006-03-28
Last Modified: 2010-04-22
I'm having a problem running a cron job on my web hosing server
this is my script to run a java program
java -cp "appservers/jakarta-tomcat-5.5x/webapps/DBTest/WEB-INF/classes" Updater

but i get the following error
/bin/sh: line 1: /usr/ngasi/contexts/paddyfitz/ Permission denied

Any Ideas
Question by:paddyfitz2005
    LVL 3

    Expert Comment

    Does this run successfully from the command line as the same uid as crontab owner?  

    It looks like whatever happens on line one of is causing the problem.  Can you post the first few lines of that script?

    Also I always use fully qualified paths in the crontab since cron runs with a limited environment.

    Author Comment

    this is all i have in my script!

    java -cp "appservers/jakarta-tomcat-5.5x/webapps/DBTest/WEB-INF/classes" Updater

    I'm new to crons and i know i have to define the java home dir but i can't find it on my web hosting server
    LVL 3

    Accepted Solution

    OK now I assume  your crontab has something like

    0 12 * * * /usr/ngasi/contexts/paddyfitz/

    And then /usr/ngasi/contexts/paddyfitz/ has:

    java -cp "appservers/jakarta-tomcat-5.5x/webapps/DBTest/WEB-INF/classes" Updater

    replace java with whatever you system returns with the "which java" command (no "").  Also fully qualify your classpath as well like /usr/local/appservers/jakarta-tomcat-5.5x/webapps/DBTest/WEB-INF/classes

    also in /usr/ngasi/contexts/paddyfitz/ put
    in the first line.  This tells the shell that it should be running the script under the Bourne shell.

    Author Comment

    ok that makes sense nut i'm not sure what you mean by

    >>replace java with whatever you system returns with the "which java" command (no "").
    LVL 3

    Expert Comment

    you need the full path for the java program  probably something like:
    if you type in
    which java
    it will give you the full path
    LVL 27

    Expert Comment

    1) add #!/bin/sh as a first line of your script
    2) give your script execution priveledges:
    chmod +x /usr/ngasi/contexts/paddyfitz/

    this should help.
    LVL 17

    Expert Comment

    logon as "root" and do what ever the cron works.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    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!

    Join & Write a Comment

    The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
    The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    754 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

    22 Experts available now in Live!

    Get 1:1 Help Now