Use crontab to run the script of executing jar program regularly in centOS6

Use crontab to run the script of executing jar program regularly in centOS6

1. Write a simple Java program

public class testshell {
  public static void main(String[] args) {
    int count = 0;
    for (String arg : args) {
      System.out.println("The " + (++count) + " parameter: " + arg);
    }
  }
}

Package the above program into centOS6

2. Write a shell script

#!/bin/bash
export JAVA_HOME=/usr/local/jdk1.8.0_91
export PATH=$JAVA_HOME/bin:$PATH
A=`date`
java -cp /root/Desktop/testshell.jar com.testshell "$A" >>/root/Desktop/c.txt

Here, please note that the absolute path address of the jar package in the Java environment variable is written

3. Edit the timer file (crontab -e)

*/1 * * * * /root/Desktop/b.sh

Summarize

The above is the script that I introduced to you in centOS6 using crontab to regularly run and execute jar programs. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Detailed explanation of how to configure windows timer to execute java jar file

<<:  MySQL 8.0.15 installation and configuration method graphic tutorial (Windows 10 X64)

>>:  Vue's new partner TypeScript quick start practice record

Recommend

MySQL 5.7.17 installation and configuration method graphic tutorial (windows10)

MySQL 5.7.17 installation and configuration metho...

Mysql join query principle knowledge points

Mysql join query 1. Basic concepts Connect each r...

Tutorial on using hyperlink tags in XHTML

Hyperlink, also called "link". Hyperlin...

Summary of Linux system user management commands

User and Group Management 1. Basic concepts of us...

js, css, html determine the various versions of the browser

Use regular expressions to determine the IE browse...

Vue gets token to implement token login sample code

The idea of ​​using token for login verification ...

Analysis of the operating principle and implementation process of Docker Hub

Similar to the code hosting service provided by G...

MySQL 8.x msi version installation tutorial with pictures and text

1. Download MySQL Official website download addre...

Detailed example of jQuery's chain programming style

The implementation principle of chain programming...

Sample code for implementing a background gradient button using div+css3

As the demand for front-end pages continues to in...

The easiest way to make a program run automatically at startup in Linux

I collected a lot of them, but all ended in failu...

Explanation of MySQL index types Normal, Unique and Full Text

MySQL's index types include normal index, uni...