Write a simple cron job to run the java class

advertisements

How can I write a cron job start from stratch to run a java class or write a cron job class with embedded java code to run?

and how can I set the timer to run every one minute (for example) that cron job?

Note : totally begineer with linux


Here is a sample sh file running a test job

#!/bin/bash
export JAVA_HOME=/usr/java/jdk1.6.0_07
echo "Java Home is $JAVA_HOME"
export CLASSPATH=.:..:$CLASSPATH:
echo "Path is is $PATH"
echo "CLASSPATH is is $CLASSPATH"
$JAVA_HOME/bin/java  TestJob
echo "$JAVA_HOME/bin/java  TestJob"

then point to it from your cronjob like so

0 5 * * * . $HOME/.profile; /path/to/command/test/job