Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
cd /scheduled/FocusUpdate
java -classpath ".:./commons-httpclient-2.0-rc1.jar:./commons-logging.jar" FocusUpdate ./airborneDownload/
I also put that same script in the cron.hourly directory. However, it didn't run it at the 50th minute, and it didn't run it in the first minute of the hour, either.
Java is accessible from anywhere, and I already run that string at the command line, so that's not an issue.
I've noticed that I can't just type .runFocusUpdate.sh to run it at the prompt--I need to type bash runFocusUpdate.sh to get it to run that script...what am I doing wrong?
Originally posted by naijaguy Java is accessible from anywhere, and I already run that string at the command line, so that's not an issue.
Just because java is in your PATH does not mean that it's in cron's PATH. You need to compare `which java` with the PATH statement. Also check that the first line of your script is the correct path to bash.
So it looks like it should find java just fine. Like I said, I think I always have to type bash and then the script name to get it to run, so I guess that last suggestion might be the best lead--it can't find bash on its own (?).
I noticed that in crontab, it says that the path to the shell is /bin/bash and in the script file I'm saying /bin/sh (and I noticed that bash is in bin and sh is also, and sh is a link to bash).
Oh, wait...cron won't use the system PATH, huh? It just uses the one in that crontab file, right? So I need to put Java in there...or if I take PATH out of the crontab file, will it then use the system's default path?
According to the PATH variable in your initial post, the PATH for cron is:
/sbin:/bin:/usr/sbin:/usr/bin
You java executable is in:
/usr/java/j2sdk1.4.2_05/bin
You'll need to add this directory to the PATH statement in the crontab. Your user PATH statement is basically defined in the login scripts. Cron does not have access to this. Anything outside of the "usual" places will not be found unless the PATH statements is modified or the full path to the executable is given.
Yeah, I just needed java in the path in the crontab file. So, once you use service to start crond, how do you check whether or not it is running? Whenever you choose to start or stop, it doesn't tell you if it was already running...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.