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

Summary of common commands for Ubuntu servers

Most of the commands below need to be entered in ...

Network configuration of Host Only+NAT mode under VirtualBox

The network configuration of Host Only+NAT mode u...

Use of TypeScript Generics

Table of contents 1. Easy to use 2. Using generic...

Introduction to Enterprise Production MySQL Optimization

Compared with other large databases such as Oracl...

MySQL conditional query and or usage and priority example analysis

This article uses examples to illustrate the usag...

In-depth interpretation of /etc/fstab file in Linux system

Preface [root@localhost ~]# cat /etc/fstab # # /e...

Detailed explanation of overflow:auto usage

Before starting the main text, I will introduce s...

A simple method to merge and remove duplicate MySQL tables

Scenario: The crawled data generates a data table...

Implementation of CSS3 button border animation

First look at the effect: html <a href="#...

Using Docker run options to override settings in the Dockerfile

Usually, we first define the Dockerfile file, and...

Two ways to start Linux boot service

Table of contents rc.local method chkconfig metho...

A simple LED digital clock implementation method in CSS3

This should be something that many people have do...

Detailed discussion of the character order of mysql order by in (recommended)

//MySQL statement SELECT * FROM `MyTable` WHERE `...