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 does Linux execute scripts on a regular basis

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of "how to achieve regular script execution in Linux". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope that this article "how to achieve regular script execution in Linux" can help you solve the problem.

Under Linux we use crontab to execute scripts on a regular basis.

View crontab input command: cat / etc/crontab

Crontab-u / / set the timing service for specific users

Crontab-l / / lists the contents of the current user timing service

Crontab-r / / Delete the current user's timing service

Crontab-e / / Edit the current user's timing service

It is recommended to list services before setting and editing: crontab-l

Shows that there is a scheduled task that executes the script command at 09:10 every day: hadoop jar / tycrtest/test2.jar

Then edit the scheduled task: crontab-e enters the editing interface and displays the existing scheduled task

* user_name command to be executed

User_name indicates that the user performing the scheduled task does not specify the default current user

Command to be executed represents the script statement to be executed.

Press I key to enter after editing, press esc and then enter: wq report and exit Note is not to enter wq is: wq

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

Use (-) to delimit the range

For example, the 0 0-3 * script means that the script is executed at 0-3 o'clock every day.

Use (,) to enumerate times

For example, 0, 15, 30, 45 * script means that 0, 15, 45, 30 minutes of every hour will execute the script.

Use (/) to specify the interval

For example: * * / 8 * script means that the script is executed every 8 hours

Combinatorial usage

The 0-20 take 10 * script means that the script is executed every 10 minutes in the first 20 minutes.

One of my timed script statements:

109 * hadoop jar / tycrtest/test2.jar default root executes the script hadoop jar / tycrtest/test2.jar at 9: 10 every day

This is the end of the content on "how Linux implements regular script execution". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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