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 view scheduled tasks

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

Share

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

This article introduces Linux how to view scheduled tasks, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.

Crontab commands are common in Unix and Unix-like operating systems and are used to set instructions that are executed periodically. This command reads instructions from a standard input device and stores them in a "crontab" file for later reading and execution.

Linux View specific methods for scheduled tasks

Crontab-l means to list all scheduled tasks crontab-r means to delete the user's scheduled tasks, when the execution of this command, all the following scheduled tasks of the user will be deleted, after the implementation of crontab-l will prompt the user: "no crontab for admin" each line in this file includes six fields, of which the first five fields are specified when the command is executed, and the last field is the command to be executed.

Each field is separated by spaces or tabs. The format is as follows:

Minute hour day-of-month month-of-year day-of-week commands

What day of the month, what day of the month, what day of the week is required to be carried out?

Legal value 00-59 00-23 01-31 01-120-6 (0 is sunday) commands (representing the script to be executed)

In addition to numbers, there are several special symbols, namely ",", "/" and "-", which represent all the numbers in the range of values, "/" means each, "/ 5" means every five units, "-" represents from a certain number to a certain number, "separates several discrete numbers.

The line in the crontab file consists of six fields, separated by spaces or the tab key. The first five fields specify the time minutes (0-59) hours (0-28) dates (1-31) months (1-12) days of the week (0-6) where 0 represents Sunday) the sixth field is a string to be executed at the appropriate time

A few examples:

Execute every five minutes: * / 5 *

Execute once an hour: 0 *

Execute once a day: 0 0 *

Execute once a week: 0 0 * 0

Execute once a month: 0 01 * *

Once a year: 0 0 1 1 *

6: 00 every morning

0 6 * echo "Good morning." > / tmp/test.txt / / Note simple echo, no output can be seen on the screen, because cron email any output to the mailbox of root.

Every two hours

0 * / 2 * echo "Have a break now." > > / tmp/test.txt

Every two hours and 8 a.m. between 11:00 and 8 a.m.

0 23-7 echo 8 * echo "Have a good dream" > > / tmp/test.txt

11:00 on the 4th of every month and from Monday to Wednesday

0 11 4 * 1-3 command line

January first at four o'clock in the morning

0 4 1 1 * command line SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root / / if there is an error or there is data output, the data will be sent to this account HOME=/ by email

Execute scripts in / etc/cron.hourly every hour

01 * root run-parts / etc/cron.hourly

Execute scripts in / etc/cron.daily every day

02 4 * root run-parts / etc/cron.daily

Execute scripts in / etc/cron.weekly weekly

22 4 * 0 root run-parts / etc/cron.weekly

Execute the scripts in / etc/cron.monthly every month

42 4 1 * * root run-parts / etc/cron.monthly

Note: "run-parts" this parameter, if you remove this parameter, you can write the name of a script to run instead of the folder name.

Execute the command at 5 min, 15 min, 25 min, 35 min, 45 min, 55 min at 4: 00, 5: 00, and 6: 00 p.m.

5 command, 15, 25, 35, 45, 55, 16, 17, 18, and

The system goes into maintenance state at 3:00 every Monday, Wednesday and Friday, and restarts the system.

00 15 * * 1Jing 3Jing 5 shutdown-r + 5

Execute the innd/bbslin instruction in the user directory at 10 minutes and 40 minutes per hour:

10pr 40 * innd/bbslink

Execute the bin/account instruction in the user directory at 1 minute per hour:

1 * bin/account executes the following two instructions (each separated by;) in the user directory at 03:20 every morning:

20 3 * (/ bin/rm-f expire.ls logins.bad;bin/expire$#@62;expire.1st) execute the / bin/rm-f expire.1st directive at 03:12 and 03:55 from 4 to 9 in January and April every year, and add the results to the mm.txt file (the mm.txt file is located in the user's own directory location).

12meme 55 34-9 1 expire.1st$#@62;$#@62;mm.txt 4 * / bin/rm-f expire.1st$#@62;$#@62;mm.txt on how to view scheduled tasks in Linux is shared here. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

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