Home >Operation and Maintenance >Linux Operation and Maintenance >What is the usage of at in linux
In Linux, at is used to specify the execution of a specified task at a specified time. The syntax is "at parameter time"; the at command is a one-time scheduled task, which will not be executed after the specified task is executed. Task, when using the at command, be sure to ensure that the atd process is started.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
What is the usage of at in Linux
The at command is a one-time scheduled task, and the daemon process atd of at will run in background mode , check the job queue to run the job. The atd daemon will check a special directory on the system to obtain the jobs submitted by the at command. By default, the atd daemon checks the directory every 60 seconds. When there is a job, it will check the job running time and if the time matches the current time , then run this job.
Note: The at command is a one-time scheduled task. After executing a task, this task will no longer be executed.
1. at command format
at [option] [time]
Ctrl D End the input of the at command
When using the at command, Be sure to ensure that the atd process is started.
2. at command parameter
option meaning
-m When the specified task is completed, an email will be sent to the user, even if there is no standard Output
-I alias of atq
-d alias of atrm
-v display The time when the task will be executed
-c Print the contents of the task to standard output
-V Display version information
-q
-f
-t
3. Time definition
at allows for a rather complex set of methods of specifying time:
can accept hh:mm (hour:minute) time specifications within the current day. If the time has passed, it will be executed the next day. For example: 04:00
You can use vague words such as midnight (late night), noon (noon), teatime (tea time, usually 4 p.m.) to specify the time.
You can use the 12-hour clocking system, that is, add AM (morning) or PM (afternoon) after the time to indicate whether it is morning or afternoon. For example: 12pm
can specify the specific date of command execution, and the specified format is month day (month day) or mm/dd/yy (month/day/year) or dd.mm. yy (day.month.year), the specified date must follow the specified time. For example: 04:00 2009-03-1
can use relative timing. The specified format is: now count time-units, now is the current time, time-units is the time unit, which can be minutes, hours, days, weeks. count is the amount of time, days, hours. For example: now 5 minutes 04pm 3 days
You can directly use today (today) and tomorrow (tomorrow) to specify the time to complete the command.
4. Related commands
1) at: perform a one-time task at a specific time;
2) atq: list the user's Scheduled tasks, if it is a super user, all user tasks will be listed. The output format of the results is: job number, date, hour, queue and user name;
3) atrm: delete at tasks based on job number;
4) Batch: Execute at tasks when the system load allows, that is, execute at tasks when the system is idle.
5. Related configuration files
1) The exact definition of the time specification can be viewed in /usr/share/doc/at-3.1.13/timespec;
2 ) By default, scheduled tasks are stored in the /var/spool/at/ folder;
3) The root user can use the at command under any circumstances, and the permissions of other users to use the at command are defined in In the /etc/at.allow (users who are allowed to use scheduled tasks) and /etc/at.deny (users who are denied the use of scheduled tasks) files, there are no files by default. You need to create the allowed user and denied user files yourself;
4) If the /etc/at.allow file exists, only the user corresponding to the user name in the file can use at;
5) If the /etc/at.allow file does not exist, / etc/at.deny exists, and all users who are not in the /etc/at.deny file can use at;
6) at.allow has a higher priority than at.deny, whether the executing user can execute the at command, First check whether the at.allow file exists before looking at the at.deny file;
7) If the /etc/at.allow and /etc/at.deny files do not exist, only the root user can use at ;
8) An empty /etc/at.deny means that any user can use the at command, which is the default configuration;
9) Generally, one of these two files is sufficient. If only a few users need to use scheduled tasks, then keep the at.allow file. If most users want to use scheduled tasks, then keep at.deny.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What is the usage of at in linux. For more information, please follow other related articles on the PHP Chinese website!