Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure scheduled restart for Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to configure timed restart in Linux". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to configure timed restart in Linux.

1. Create a new .sh file in the service directory

Cd / opt/tsp/

Touch restart.sh

\ 2. View

3. Edit restart.sh script

Jps-l | grep wx | awk'{print $1}'| xargs kill-9 nohup java-jar / opt/tsp/wx.jar > / opt/tsp/wx.out 2 > & 1 &

4. Explain the meaning of the script

Jps-l | grep wx (ps-ef | grep wx) query the process of wx.jar

Awk'{print $1} 'gets the first column of the process query result structure

| | xargs kill-9 kill drops the process number queried |

Nohup java-jar / opt/tsp/wx.jar > / opt/tsp/wx.out 2 > & 1 & start command

5. Write scheduled tasks, enter the editor, press the I button, and you can enter it.

\ 6. Explain the command 40 15 * * 5 sh / opt/tsp/restart.sh execute the restart.sh script at 15:40 on Friday

Write rules:

The first five bits are timed and the time period is described as follows:

The first * indicates minutes: value range: 0-59

The second * indicates the hour: value range: 0-23

The third * indicates the number of days: value range: 1-31

The fourth * indicates the month: value range 1-12

The fifth * indicates weekly: value range: 0-6

"*" represents a number in the range of values, "/" represents "every", "-" represents from a certain number to a certain number, "," separates several discrete numbers.

7. Cron service

/ sbin/service crond start/sbin/service crond stop/sbin/service crond restart/sbin/service crond reload/sbin/service crond status Thank you for your reading. The above is the content of "how to configure scheduled restart of Linux". After the study of this article, I believe you have a deeper understanding of how to configure scheduled restart of Linux, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report