Saturday, 25 February 2017

Using the scheduler at the tasks at planning with the help of the program on Linux

Using the scheduler at  the tasks at planning with the help of the program on Linux 

In some cases, you may need to perform a single task at a given time, just for this purpose is best suited at a program that also allows you to execute commands while reducing the system load. 

Another reason could be use at your desire to execute the command takes a long time, and disconnect from the server; at its suitable for this task, but I would also recommend to read the articles about running a command in the background and use the utility screen.

Thus, the main objective of the program is at "a single execution plan objectives." In this respect, it is similar to cron program, which is usually used for planning recurring tasks; let's look at some basic examples of the use of this program. 
At program it is part of a set that consists of four programs: at, batch, atq and atrm: 

at performing the task at the scheduled time. 
atq lists pending tasks for each user; in the case of super-user, displays all pending task.
atrm removes tasks specified IDs.
batch executes tasks during periods of low usage; in other words, when the load average drops below 1.5, or the value of the value that is specified in the call atd.

Using at
After starting at prompts you to enter a series of commands to execute. To finish entering commands, use the keyboard shortcut CTRL-D. Description of the main parameters at the command line is shown below:

at [-m] [-q queue] [-f file] TIME

The value of these parameters: 

-q is used to specify the queue. The queue is indicated by a single letter; Queues are considered correct queue identifiers from a to z and A to Z. The queue identifier a default, and the queue identifier b is a queue for batch programs. Commands from queues with identifiers located further alphabetically executed with higher priority (nice). The special queue "=" is reserved for teams that run at the moment. If the command is added to the queue, an identifier which is a capital letter, it is believed that the team transferred batch program. In the event that the program atq passed queue identifier, the program displays the commands that are only in this queue. 
-m allows you to send a message by e-mail after the task, even if the execution of the program does not withdraw anything.
-f command allows you to read from a file rather than from standard input.
As at the time it takes a string in a format compatible with the POSIX.2 standard. Takes a string specifying the time in the format HH: MM, which allows to execute a command at a designated time during the day. You can also set a day to run the command with a line indicating the date in the name of the month and day with optional indication of the year and set the date string format MMDDYY or MM / DD / YY or DD.MM.YY. Note the date must follow the instructions of time.

During the test the exact time was as follows: 

events Wed Oct 17 22:31:05 CEST 2016 

In that case, if you specify only the time, the task will be scheduled for the next moment of time to achieve this, for example, I asked a 20.00 time, and execution task has been scheduled for the following day at this time: 

#at -f 20:00 
warning: commands The will of the BE Executed using the / bin directory / the sh 
the job 4 at Thu Oct 18 20:00:00 2016 

in this case, if you set the time, which has not come today, the performance of the task will be scheduled on the same day: 

#at -f 22:35 
warning: commands the will of the bE Executed using the / bin directory / the sh 
the job 5 at Wed Oct 17 22:35:00 2016 

this another example of using the keyboard shortcut CTRL + D to complete a command input: 

AT midnight on Friday 
warning: commands The will of the BE Executed using the / bin directory / the sh 
AT> the cp -a / project /-source / * / the backup /-source / ^ the C 
the job 6 at Fri Oct 19 00:00:00 2016 

View all scheduled tasks with atq 
you can use the program as an alternative to atq at -l command to view a list of planned or currently running tasks, and the only argument of this program is to -q specifying a particular queue. 

3 Thu Oct 18 10:25:00 2016 a linuxaria
4 Thu Oct 18 20:00:00 2016 a linuxaria
6 Fri Oct 19 00:00:00 2016 a linuxaria

In my view, the program output is not particularly useful, since you can not see what the command is executed in the framework of the task with ID 3, or any other problem.
To see what will be done in the framework of the task, you can use the following command:

AT -c identifikator_zadachi

This finding allows a much better understanding of the purpose of the task.
Removing a scheduled task using atrm

We have learned to view a list of scheduled tasks and, if desired, their contents, it is now time to consider a way to remove them from the queue by using atrm program or at -d command to delete a specific task.
Thus, to remove problem with the ID 3, you simply need to enter the command:

atrm 3

This command does not output anything to the console, but after the performance you can be sure to remove the problem with atq command.
Restricting User circle program at

/etc/at.allow Files and /etc/at.deny set of users who can schedule tasks for later execution using the program at, and batch. As the format of these files is a simple list of usernames, one per line. Using spaces in these files is not allowed.

The root user can use at or batch program under any circumstances.

If /etc/at.allow file exists on the basis of its established range of users who are allowed to planning problems, but usually in the systems of this file does not exist.

If the file does not exist /etc/at.allow checked /etc/at.deny file that typically contains a long list of "system users" such as bin, backup, ftp or www-data, which is prohibited for task scheduling. 

No comments:

Post a Comment