Linux – Execute java cron job to run a jar file

1. Create a Cron Job

To create a cron job, in terminal, type crontab -e to edit the cron job. Review following examples :

1.1 Run daily at 00:00, accepts two parameters.

# run everyday
0 0 * * * java -jar /home/mkyong/crawler/webcrawler.jar param1 param2

1.2 Run daily at 02:00 am, pass rir.name as a system property with -D option.

# run everyday at 2am
0 2 * * * java -jar -Drir.name="ripe" /home/mkyong/crawler/whoiscrawler.jar

1.3 Run hourly, assume this jar is logging message with the logback framework.

# run every hour
0 * * * * java -jar -Dlogback.configurationFile=/home/mkyong/logback.xml /home/mkyong/crawler/crawler.jar

https://www.mkyong.com/java/java-cron-job-to-run-a-jar-file