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 use the at command in linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Editor to share with you how to use the at command in linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The Linux at command and batch read commands from standard input or a specified file, which are executed with / bin/sh at a later time. The Linux at command allows for fairly complex timing, which extends the POSIX.2 standard. He accepts the time style of HH:MM, which is used to specify that a job be run at a certain time of day. (if the time has passed, it is assumed to be the next day.)

You can specify midnight (midnight), noon (noon) or teatime (4 p.m.), and you can specify the morning or afternoon of the day with the AM or PM suffix. You can give the style of month-name day plus an optional year to specify the date on which the Linux at command will be run, or the MMDDYY, MM/DD/YY, or DD.MM.YY style to specify the date on which the Linux at command will be run. The date must be specified after the time specified. You can also give a style like now + counting time units, where the time units can be minutes, hours, days or weeks, you can add a today suffix to the time to specify that the Linux at command runs the job today, and you can add a tomorrow suffix to the time to specify the Linux at command to run the job tomorrow.

For example,

To run a job at 4 p.m. three days later, the Linux at command time parameter can be specified as 4pm + 3 days.

To run a job at 10:00 on July 31st, the Linux at command time parameter can be specified as 10am Jul 31

To run a job at 1 a.m. Tomorrow, the Linux at command time parameter can be specified as 1am tomorrow.

Run the program regularly using the Linux at command, 2005-12-28 18:16:50 by Johnny

Use the Linux at command to run the program periodically

1. To run a task using cron

The drawback of cron tasks is that they are planned to run frequently. What if we just want a specific task to run once?

So, this is the time to use the at monitor program.

Setting up the Linux at command is very simple, indicating when to run, and when it will be run. The Linux at command is similar to the print process, placing the task in the / var/spool/at directory and running it at a specified time.

The Linux at command is equivalent to another shell. When the at time command is run, it sends commands one by one and can enter any command or program.

The at now + time command can indicate the task.

Suppose you are dealing with a large database that processes data when others are not using the system, such as 02:05 in the morning. Then we should first set up the / home/mj/airplane script management database and plan to process the results in the / home/mj/air-safe file. The normal way to start the following command is:

# at 2:05 tomorrow

At > / home/mj/airplane > / home/mj/air-safe

At > Ctrl+D

Time representation in AT Time

An example of time

The Minute at now + 5 minutes task runs in 5 minutes

The Hour at now + 1 hour task runs in an hour

The Days at now + 3 days task runs after 3 days

The Weeks at now + 2 weeks task runs in two weeks

The Fixed at midnight task runs at midnight

The Fixed at 10:30pm mission begins at 10:30 in the evening

Fixed at 1:00 12-20-04 mission begins at 1: 00 a.m. on December 20, 2004

two。 View the tasks currently waiting to be performed

After entering a task, you can use the atq command to see the tasks currently waiting for execution, and the output provides information such as task number, user and task execution time.

# atq8 2004-12-15 02:05 a mj

The an inside indicates whether it is an at task or a task generated by the batch command.

3. Delete Linux at Command Task

The task of deleting a Linux at command is relatively simple and can be easily solved using the atrm command.

For example, if I know the queue number of the task, I can delete it:

# atrm 8

The at task with queue number 8 is deleted.

At-l list

At-r removal

The above is all the contents of the article "how to use at commands in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Servers

Wechat

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

12
Report