crontab problem

Hi,

I have a shell script which I want to execute via a crontab every 2 minutes. I edited my crontab as follows:

bash-2.05$ crontab -e
2 * * * * /opt/vignette/V7/logs/dblogins.sh

But the above doesnt seem to do anything.  

Any suggestions as to whats wrong ?

thnx,

sgauchoAsked:
Who is Participating?
 
ramazanyichConnect With a Mentor Commented:
provide full path to LogDb.jar  file
0
 
ramazanyichCommented:
you definiton is wrong. It should be:
2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /opt/vignette/V7/logs/dblogins.sh
0
 
ramazanyichCommented:
your original definition says that  script will  be executed on second minute of every hour
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
sgauchoAuthor Commented:
Nope, its still not executing my script. can I debug this somehow ?

 Also, isnt the definition huge ? If i wanted to execute it every minute, it wud get even bigger.

thanks,
0
 
liddlerCommented:
To do it every minute:
* * * * * /opt/vignette/V7/logs/dblogins.sh

Have a look in /var/cron/log and check your mail, cron messages should be mailed to you
0
 
OtetelisanuCommented:
You can make a script for every minute :

while true
do
sleep 60

Your_script
done

and you start as

nohup ./script &
0
 
ramazanyichCommented:
could you send the script ? Does it run from command line ?
0
 
OtetelisanuCommented:
1. you can from comand line run
Example:
while true
do
ls -l
sleep 60
done

2. you can from the script
     Example : my_script
  #
Envirnement variable

while true
do
ls -l >> /directory/file.log
sleep 60
done

and start as
nohup ./my_script &

0
 
sgauchoAuthor Commented:
Hi,

pl tell me something. I have set the classpath in my env and also in my .profile. I can execute the script fine from command line and if I place a echo $CLASSPATH in the shell script, that too executes fine but when executing via the crontab, It reports an error saying :

Your "cron" job on wcmms01
/opt/vignette/V7/logs/dblogins.sh

produced the following output:

Exception in thread "main" java.lang.NoClassDefFoundError: com/oberon/runtime/ZipFileRuntime

I am quite sure this is a classpath problem. Any suggestions as to how I can resolve this??

thnx,
0
 
jlevieCommented:
A job running from cron will only have the basic system environment. It won't use your .profile so any env vars you set there won't be in effect. To fix this you'll need to add the setup for CLASSPATH to your script that you run from cron.
0
 
sgauchoAuthor Commented:
Hi,

Ok, I edited my dblogins.sh as follows:

CLASSPATH=/opt/vignette/V7/vbis/lib/vbisclasses.jar:/usr/java:/usr/java/bin:/usr
/java/lib/tools.jar:/opt/vignette/V7/logs/ojdbc14.jar:/opt/vignette/V7/logs/LogD
b.jar
export CLASSPATH
LD_LIBRARY_PATH=/opt/vignette/V7/vbis/lib:
export LD_LIBRARY_PATH

echo $CLASSPATH

echo $LD_LIBRARY_PATH

java com.oberon.runtime.ZipFileRuntime LogDb.jar  -fname /opt/vignette/V7/logs/W
CM_export_19760817.csv


ANd the output I am getting now from the CRON is :

Your "cron" job on wcmms01
/opt/vignette/V7/logs/dblogins.sh

produced the following output:

/opt/vignette/V7/vbis/lib/vbisclasses.jar:/usr/java:/usr/java/bin:/usr/java/lib/tools.jar:/opt/vignette/V7/logs/ojdbc14.jar:/opt/vignette/V7/logs/LogDb.jar
/opt/vignette/V7/vbis/lib:
java.util.zip.ZipException: No such file or directory
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:112)
        at java.util.zip.ZipFile.<init>(ZipFile.java:72)
        at com.oberon.runtime.ZipFileApplicationSource.<init>(Unknown Source)
        at com.oberon.runtime.ZipFileRuntime.main(Unknown Source)

Why am I getting this error ?

TIA
0
 
sgauchoAuthor Commented:
Hi again,

The while loop works fine except on the production server I need the script to run every day at 10 minutes to midnight (1150 pm everyday). Would it be feasible and advisable to do this within the script ? wudnt it be better to execute the script via a crontab ?

thnx
0
 
sgauchoAuthor Commented:
I have provided the full path to LogDb.jar  in my classpath
0
 
ramazanyichCommented:
But why do you use it as parameter for your class ???
0
 
ramazanyichCommented:
java com.oberon.runtime.ZipFileRuntime LogDb.jar  -fname /opt/vignette/V7/logs/WCM_export_19760817.csv

It means that args[0] for ZipFileRuntime will be LogDb.jar
0
 
sgauchoAuthor Commented:
The class is part of an application compiled by another software and which requires a parameter to be supplied dynamically at runtime.

The command java com.oberon.runtime.ZipFileRuntime LogDb.jar  -fname /opt/vignette/V7/logs/WCM_export_19760817.csv works just fine when executed at the command line or via a shell script. Its only when I try to execute the script via a crontab that the problems start.
0
 
ramazanyichCommented:
Probably your class reads that file then it is provided as parameter, that's why you should try to provide full pathname to that jar file. Just try it. Hope that will help.
0
 
sgauchoAuthor Commented:
ramazanyich, You were right! thnx a bunch..

Just one last question before I close this issue. I need the crontab to execute the script everyday at 2340 hours or 20 minutes to midnight.

thnx
0
 
ramazanyichCommented:
40 23 * * * /opt/vignette/V7/logs/dblogins.sh
0
 
sgauchoAuthor Commented:
Thnx a bunch. :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.