Get the App
SLTechnology News&Howtos  ›  Servers  › 

Scheduled tasks under linux can be divided into several categories

Shulou Source: shulou.com Published: 2022-06-02 00:31:23 10月05日 Update

This article mainly introduces the scheduled tasks under linux can be divided into several categories, the article is very detailed, has a certain reference value, interested friends must read it!

Scheduled tasks are a very good function provided to us by the operating system, and we often use scheduled tasks to deal with some things. such as regularly backing up website data every day, executing the data statistics program every month, monitoring the operation of the server (sending a message to the administrator when an error occurs), and so on.

Scheduled tasks under linux are divided into two categories: scheduled tasks that are executed only once, and scheduled tasks that are executed periodically. Today, let's take a look at scheduled tasks that are executed only once, and scheduled tasks that are executed periodically will be described in the next article.

Atd service

We only perform the planned task once, and we do it through the at command. To execute the at command, we need to start the atd service first. The commands to view the health status of the atd service and enable the atd service are as follows:

# check atd service status # systemctl status atd # enable atd service # systemctl start atd

At rights management

When you use at to generate a new task, the task is placed in the / var/spool/at directory as a text file.

# ll / var/spool/attotal 8 RWX-1 root root 2890 Nov 7 16:30 a0000201981b23 date > > / root/at.txtat > date > > / root/at.txtat > job 4 at Sat Nov 7 17:01:00 2020

View scheduled tasks

Use the-l option to view scheduled tasks, and use the-c option if you want to see specific commands. In addition, you can use the atq command to view it.

# at-L6 Sat Nov 7 17:13:00 2020 a root3 Wed Nov 11 17:00:00 2020 a root# atq6 Sat Nov 7 17:13:00 2020 a root3 Wed Nov 11 17:00:00 2020 a root

Remove scheduled tasks

Scheduled tasks that have not been performed can be deleted through at-d or atrm.

# at-d atrm 6

Another benefit of using at to generate scheduled tasks is that offline management can be done.

The above are the scheduled tasks under linux can be divided into several categories of all the content, thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Tasks commands services files two systems management content lists cycles periodicity commonly used forms data time permissions status articles runs next Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Xiaomi Redmi OPPO Reno Linux