LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 08-17-2004, 02:54 PM   #1
naijaguy
Member
 
Registered: Aug 2004
Posts: 88

Rep: Reputation: 15
trying to get cron to run


I'm logged in as root, and I'm trying to get cron to run. I edited /etc/crontab so that it looks like this:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
50 * * * * root /scheduled/FocusUpdate/runFocusUpdate.sh


That shell script looks like this:

#!/bin/sh

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.
 
Old 08-17-2004, 02:58 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Is the script actually executable?
 
Old 08-17-2004, 03:00 PM   #3
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Is java in the PATH that you specified at the top of the crontab?
 
Old 08-17-2004, 03:12 PM   #4
naijaguy
Member
 
Registered: Aug 2004
Posts: 88

Original Poster
Rep: Reputation: 15
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?
 
Old 08-17-2004, 07:25 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Are the permissions for the file runFocusUpdate.sh set for executable?
 
Old 08-17-2004, 07:39 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by michaelk
Are the permissions for the file runFocusUpdate.sh set for executable?
Thanks for re-phrasing that
 
Old 08-17-2004, 07:45 PM   #7
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Quote:
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.

Last edited by stickman; 08-17-2004 at 07:47 PM.
 
Old 08-18-2004, 11:06 AM   #8
naijaguy
Member
 
Registered: Aug 2004
Posts: 88

Original Poster
Rep: Reputation: 15
Here are the permissions:

[root@localhost etc]# ls -l cron.hourly/
total 4
-rwxr-xr-x 1 root root 161 Aug 17 14:44 runFocusUpdate.sh
[root@localhost etc]#

Here are the results of which java:
[root@localhost root]# which java
/usr/java/j2sdk1.4.2_05/bin/java

Here is my PATH:

[root@localhost root]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/usr/java/j2sdk1.4.2_05/bin/
[root@localhost root]#


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?
 
Old 08-18-2004, 01:12 PM   #9
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
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.

Last edited by stickman; 08-18-2004 at 01:14 PM.
 
Old 08-18-2004, 04:04 PM   #10
naijaguy
Member
 
Registered: Aug 2004
Posts: 88

Original Poster
Rep: Reputation: 15
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...
 
Old 08-18-2004, 04:06 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
ps -A | grep cron


Cheers,
Tink
 
Old 08-18-2004, 04:57 PM   #12
naijaguy
Member
 
Registered: Aug 2004
Posts: 88

Original Poster
Rep: Reputation: 15
So, if something shows up, then it's running, right? This was my output:

27386 ? 00:00:00 crond


What's that question mark for? Does it not report a time since it's a service/daemon?
 
Old 08-18-2004, 05:32 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
? means that it's not running in tty/pty, and the 00:00:00
time means that it's a very well behaved process
using hardly any CPU cycles ;)


Cheers,
Tink
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can't get cron to run my script. dr_zayus69 Linux - Software 6 04-12-2005 06:34 PM
How to run the cu command by cron tcore Linux - General 0 03-07-2005 08:22 AM
could cron/any batch run at my will sheikhsa Linux - Newbie 2 09-23-2004 08:00 PM
Did my Cron job run? ryedunn Linux - Newbie 2 02-25-2004 08:59 AM
Cron job does not run brentos Linux - General 6 12-12-2003 02:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration