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

A brief discussion on which fields in Mysql are suitable for indexing

Table of contents 1 The common rules for creating...

React antd realizes dynamic increase and decrease of form

I encountered a pitfall when writing dynamic form...

Front-end JavaScript Promise

Table of contents 1. What is Promise 2. Basic usa...

html opens a new window with a hyperlink and can control window properties

1. The window size opened by the HTML hyperlink C...

Jmeter connects to the database process diagram

1. Download the MySQL jdbc driver (mysql-connecto...

Ubuntu 20.04 Best Configuration Guide (Newbie Essential)

1. System Configuration 1. Turn off sudo password...

In-depth analysis of the role of HTML <!--...--> comment tags

When we check the source code of many websites, w...

How to backup MySQL regularly and upload it to Qiniu

In most application scenarios, we need to back up...

Use of Vue3 table component

Table of contents 1. Ant Design Vue 1. Official w...

Implementation of Docker deployment of Django+Mysql+Redis+Gunicorn+Nginx

I. Introduction Docker technology is very popular...

How to use vue filter

Table of contents Overview Defining filters Use o...

The difference between this.$router and this.$route in Vue and the push() method

The official document states: By injecting the ro...

Solution for multiple Docker containers not having the same port number

Background In Docker, four containers are created...