Linux/centos at Instruction detailed

Source: Internet
Author: User
Tags aliases

At

Timed tasks, specifying a time to perform a task that can only be performed once.


Syntax: # at [parameter] [TIME]

at> Execution of instructions

Exit at Command Ctrl+d

Command Prerequisites:

The ATD process needs to be turned on (ATD is started by default with system boot in Redhat)

The test found that there is no own at service in the centos6.5 mini version, so you need to download it yourself

# yum-y Install at


# Ps-ef | grep ATD# #查看是否开启atd

#/etc/init.d/atd start# #开启atd

# chkconfig--level 2345 ATD on# #设置atd开机启动


Query deletes the current pending task

Queries the current wait task and is not displayed after it is executed

# ATQ


Delete a task in the system that is being set up by an at and waiting to be executed

# ATRM task's work number

Example: # ATRM 17



Common parameters:

-M: When the specified task is completed, the user will be sent a message, even if there is no standard output

Aliases for-I:ATQ

Aliases for-D:ATRM

-V: Shows when the task will be executed

-C: Print the contents of the task to standard output

-V: Display version information

-Q: Add < queue after > use specified queue

-F: Append < file > read into task from specified file instead of reading from standard input

-T: Back < time parameters > submit a task to run in the form of a time parameter



Time: Defines when to perform the at task, in the following format:

1, hh:mm

Note: At today's hh:mm time, if the time has passed, tomorrow's hh:mm will do this task.

Ex> 04:00


2, hh:mm YYYY-MM-DD

Description: Specifies that the task be carried out at a particular time of day of the month of the year

Ex> 04:00 2009-03-17


3, HH:MM[AM|PM] [Month] [Date]

A provision for the task at some point in a certain month of the year

Ex> 04pm March 17


4, HH:MM[AM|PM] + number [Minutes|hours|days|weeks]

Description: Specify how much time will be added to the task at a certain point in time.

Ex> now + 5 minutes

Ex> 04pm + 3 days



Time format extension:

At allows you to use a fairly complex set of time-specific methods.

1, can accept in the day hh:mm (Hours: minutes) type of time designation. If the time has passed, then it will be executed the next day.

2, can use Midnight (late night), noon (noon), Teatime (tea time, usually 4 o'clock in the afternoon) and other vague words to specify the time.

3, can use the 12-hour timekeeping system, that is, after the time plus AM (morning) or PM (afternoon) to indicate whether it is morning or afternoon.

4, can specify the specific date of the command execution, the format is Month Day (month) or mm/dd/yy (Month/day/year) or Dd.mm.yy (day. Month), the specified date must be followed by the specified time.

5, can use the relative timing method. The specified format is: Now + Count Time-units, today is the current time, Time-units is the time unit, here can be minutes (minutes), hours (hours), Days (day), Weeks (week). Count is the amount of time, days, hours.

6. Be able to specify the time to complete the command directly using today (present), Tomorrow (Tomorrow).



Restrict users ' use rights

Premise: Many hosts by the so-called attack, most often found that their system is a lot of hacking programs, these programs are likely to use a number of scheduled tasks to run or collect your system running information, and regularly sent to the hacker. So, unless it's your approved account, don't let them use the AT command first.

The control file used by the AT command to restrict user control of use

Control Files directory:/etc/at.allow and/etc/at.deny

Control file Usage Rules:

1: First find/etc/at.allow This file, write in this file user can use at, no user in this file can not use at (even if not written in At.deny);

2: If/etc/at.allow does not exist, look for/etc/at.deny this file, if it is written in this At.deny user can not use at, but not in this At.deny file users will be able to use the AT command.

3: If none of the two files exist, then only root can use the AT command.

4: In general distributions, because it is assumed that all users on the system are trustworthy, the system usually retains an empty/etc/at.deny file, which means that all people are allowed to use the AT command.

5: If you do not want some users to use at, the user's account will be written to/etc/at.deny! One account to write a line.

# Vi/etc/at.allow



Precautions

1, if the command output at the wrong path will send the results in the form of mail to the user

2, when a task is created will be assigned to a task number, and will be queued inside the/var/spool/at. It is not recommended to use VI Editor to modify, error-prone.



Example:

Example 1: Three days after 5 o'clock in the afternoon Chung execution of/bin/ls

# at 5pm + 3 days

At>/bin/ls

At> <EOT>

Job 7 at 2013-01-08 17:00


Example 2: Tomorrow 17 o'clock, the output time is within the specified file

# at 17:20 tomorrow

At> Date >/root/doiido.log

At> <EOT>

Job 8 at 2013-01-06 17:20


Example 3: After scheduling a task, use the ATQ command to see that the system is not performing a work task before it is executed

# ATQ

8 2013-01-06 17:20 a root

7 2013-01-08 17:00 a root


Example 4: Delete a task that has already been set

# ATQ

8 2013-01-06 17:20 a root

7 2013-01-08 17:00 a root

# ATRM 7

# ATQ

8 2013-01-06 17:20 a root


Example 5: Displaying the contents of a task that has been set

# At-c 8

#!/bin/sh

# Atrun Uid=0 gid=0

# Mail Root 0

echo "Hello"

Date > Doiido.log



Extended instruction Batch

Batch is a special version of the AT command that is used when performing tasks that consume a lot of resources, only when CPU requirements are less than 80% of CPU capacity

# Batch

at> echo "HI" >/dev/tty2

The tasks created by batch are also viewed through ATQ, atrm delete


This article from "Doiido" blog, reproduced please contact the author!

Linux/centos at Instruction detailed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.