At Command in Linux
We hope this post helped you to find out At Command in Linux
at is a command-line utility that permits you to schedule instructions to be executed at a selected time. Jobs created with
at are executed solely as soon as.
On this article, we’ll clarify find out how to use
at and its companion utilities
atrm to view, delete, and create jobs to be executed at a later time.
Relying on the distribution,
at might or might not be current in your Linux system.
at will not be put in, you may simply set up it utilizing the bundle supervisor of your distribution.
at on Ubuntu and Debian
sudo apt update
sudo apt install at
at on CentOS and Fedora
sudo yum install at
As soon as this system is put in ensure that
atd, the scheduling daemon is working and set to start out on boot:
sudo systemctl enable --now atd
How you can Use the
The simplified syntax for the
at command is as follows:
at command takes the date and time (
runtime) if you need to execute the job as a command-line parameter, and the command to be executed from the usual enter.
Let’s create a job that might be executed at 9:00 am:
When you hit
Enter, you’ll be offered with the
at command immediate that almost all typically begins with
at>. You additionally see a warning that tells you the shell wherein the command will run:
warning: commands will be executed using /bin/sh at>
Enter one or more command you want to execute:
tar -xf /home/linuxize/file.tar.gz
When you’re done entering the commands, press
Ctrl-D to exit the prompt and save the job:
at> <EOT> job 4 at Tue May 5 09:00:00 2020
The command will show the job quantity and the execution time and date.
There are additionally different methods to go the command you need to run, in addition to coming into the command within the
at immediate. A method is to make use of
echo and pipe the command to
echo "command_to_be_run" | at 09:00
Another option is to use Here document:
at 09:00 <<END
To read the commands from a file instead of the standard input, invoke the command with
-f option following by the path to the file. For example, to create a job that will run the script
at 09:00 -f /home/linuxize/script.sh
By default if the command produces output,
at will send an email including the output to the user once the job is completed. Invoke
at with the
-M option to suppress the email notification:
at 09:00 -M
-m to send an email even if there is no output:
at 09:00 -m
batch Command #
batch or its alias
at -b schedules jobs and executes them in a batch queue when the system load degree allow. By default, the roles are executed when the system load common is under 1.5. The worth of the load might be specified when invoking the
atd daemon. If the system load common is larger the desired one, the roles will wait within the queue.
To create a job with
batch, go the instructions you need to execute:
echo "command_to_be_run" | batch
Specifying the Execution Time #
at utility accepts a variety of time specs. You possibly can specify time, date, and increment from the present time:
- Time – To specify a time, use the
HHMMtype. To point a 12-hour time format, use
pmafter the time. You can even use strings like
teatime(16:00). If the desired time is handed, the job might be executed the following day.
- Date – The command permits you to schedule job execution on a given date. The date might be specified utilizing the month title adopted by the day and an non-compulsory yr. You need to use strings, akin to
right this moment,
tomorrow, or weekday. The date might be additionally indicated utilizing the
- Increment –
atadditionally accepts increments within the
now + depend time-unitformat, the place
dependis a quantity and
time-unitmight be one of many following strings:
Time, date and increment might be mixed, listed here are few examples:
- Schedule a job for the approaching Sunday at a time ten minutes later than the present time:
at sunday +10 minutes
- Schedule a job to run at 1pm two days from now:
at 1pm + 2 days
- Schedule a job to run at 12:30 Oct 21 2020:
at 12:30 102120
- Schedule a job to run one hour from now:
at now +1 hours
You can even specify a time and date within the
[[CC]YY]MMDDhhmm[.ss] utilizing the
-t possibility. Right here is an instance:
at -t 202005111321.32
Specifying Queue #
By default, the roles created with
at are scheduled within the queue named
a and jobs created with
batch are scheduled within the
Queries can have a reputation from
Z. Queues with decrease letters run with decrease niceness, which suggests they’ve precedence over these with larger letters.
You possibly can specify the queue with the
-q possibility. For instance, to set a job within the
L queue, you’ll run:
at monday +2 hours -q L
Listing Pending Jobs #
To list the user’s pending jobs run the
at -l command:
The output will list all jobs, one per line. Each line includes the job number, date, time, queue letter, and username.
9 Tue May 5 12:22:00 2020 a linuxize 12 Wed Oct 21 12:30:00 2020 a linuxize 15 Tue May 5 09:00:00 2020 a linuxize 6 Tue May 5 09:00:00 2020 a linuxize 13 Mon May 4 23:08:00 2020 a linuxize 11 Wed Jul 1 10:00:00 2020 a linuxize 4 Tue May 5 09:00:00 2020 a linuxize
atq is invoked as an administrative user, it will list the pending jobs of all users.
Removing Pending Jobs #
To remove a pending job invoke the
at -r command followed by the job number. For example, to remove the job with number nine, you would run:
Restricting Users #
/etc/at.allow files allow you to control which users can create jobs with
batch command. The files consist of a list of usernames, one user name per line.
By default, only the
/etc/at.deny file exists and is empty, which means that all users can use the
at command. If you want to deny permission to a specific user, add the username to this file.
/etc/at.allow file exists only the users who are listed in this file can use the
If neither of the files exists, only the users with administrative privileges can use the
at utility reads instructions from normal enter and executes them at a later time. Not like crontab, jobs created with
at are executed solely as soon as.
For extra details about all accessible choices of the
at command sort
man at in your terminal.
We hope the At Command in Linux help you. If you have any query regarding At Command in Linux drop a comment below and we will get back to you at the earliest.
We hope this post helped you to find out At Command in Linux . You may also want to see – Kill Command in Linux