We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

cron job: permission denied

paddyfitz2005
on
Medium Priority
470 Views
Last Modified: 2010-04-22
hi
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/script2.sh: Permission denied

Any Ideas
Comment
Watch Question

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

It looks like whatever happens on line one of script2.sh 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

Commented:
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
OK now I assume  your crontab has something like

0 12 * * * /usr/ngasi/contexts/paddyfitz/script2.sh

And then /usr/ngasi/contexts/paddyfitz/script2.sh 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/script2.sh put
#!/bin/sh
in the first line.  This tells the shell that it should be running the script under the Bourne shell.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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 "").
you need the full path for the java program  probably something like:
/usr/local/jdk/bin/java
if you type in
which java
it will give you the full path
Artysystem administrator
Top Expert 2007

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

this should help.
Dushan De SilvaTechnology Architect

Commented:
logon as "root" and do what ever the cron works.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.