at daemon (Demo)

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Difficulty
Intermediate
Video Transcription
00:00
>> Hey, Cybrarians, and welcome back to
00:00
the Linux plus course here at Cybrary.
00:00
I'm your instructor, Rob Goelz.
00:00
In today's lesson, we're going to be
00:00
discussing the at command
00:00
>> and hanging out with that ats.
00:00
>> Upon completion of today's lesson,
00:00
you're going to be able to understand when
00:00
the at command would be used,
00:00
we're going to learn about the at command syntax,
00:00
and then we're going to run the at command
00:00
to schedule jobs during our demo.
00:00
The at command allows you to schedule a job to run at
00:00
a specified time using a natural language syntax.
00:00
It's helpful to run at when you want to run
00:00
a non-recurring job because you
00:00
can just kick it off really quickly.
00:00
The at daemon or atd runs
00:00
in the background of the system.
00:00
An atd checks the directory of var/spool/at
00:00
when we're talking about RPM-based systems CentOS.
00:00
It looks in there for jobs submitted and it checks
00:00
every 60 seconds by default.
00:00
Now the basic syntax we see with at is at,
00:00
>> and then an optional file name and time.
00:00
>> at does except the file parameter using
00:00
the -f option before the time,
00:00
and then it will run the script at the time specified.
00:00
For example, if we say at -f script.sh
00:00
>> now plus one minute,
00:00
>> it will run that script in one minute from now.
00:00
Without specifying a file, at defaults
00:00
>> into an interactive syntax,
00:00
>> it drops into a shell,
00:00
and then what we can do is enter
00:00
the command or script to run and hit Enter,
00:00
and then on the next line,
00:00
>> we hit Control D to schedule the job.
00:00
>> Now, when we're scheduling these jobs,
00:00
the time specified can be fixed,
00:00
meaning you can say something like at noon,
00:00
at midnight, or 8:05,
00:00
or it can be relative, at now, at 10 minutes from now.
00:00
Now, regardless of how we submit the job,
00:00
if you do it via a file or just interactively,
00:00
all jobs submitted wind up in a queue
00:00
and in CentOS, that queue is found at var/spool/at.
00:00
Job entries in the queue
00:00
>> can be seen with the command atq as well.
00:00
>> Each job in a each queue receives a number.
00:00
>> If you decide, oh, no,
00:00
I don't want to run this command,
00:00
you can actually go and remove
00:00
the job by using the atrm command,
00:00
at A-T remove and then the job number.
00:00
Let's go ahead and take a look at
00:00
this with some demo time.
00:00
Here we are in our demo environment,
00:00
and let's first run a command interactively.
00:00
We'll say at now plus three minutes.
00:00
What it's going to do is it's going to drop us
00:00
into a shell and we can just run,
00:00
let's just run a echo.
00:00
This is an at test,
00:00
and we're going to pen this to temp.
00:00
We'll create a file here called attest,
00:00
and we hit Enter and then Control D,
00:00
and we can see that that is set up,
00:00
we can hit atq,
00:00
and we can see that the job is number 2.
00:00
We could do a sudo ls on /var/spool/at,
00:00
and inside of here,
00:00
we can actually see that there is an entry.
00:00
If we try and look at this,
00:00
we can do a sudo ls on var/spool/at
00:00
and this weird number.
00:00
We could do a less on it.
00:00
We're going to see that this is carrying a lot of
00:00
information about the user environment.
00:00
But if we go down to the very bottom,
00:00
we can see what it's actually doing is
00:00
just the echo that we submitted here.
00:00
This echo, this is an attest to
00:00
temp attest. There's no limit.
00:00
This is the Control D that we ran at the end of it.
00:00
Now, if we wait a little bit,
00:00
we should be able to see this output in
00:00
less /temp/attest,
00:00
and we see that, that is run.
00:00
We see a display that this is an at test.
00:00
Then, we'll just run that one time with at D.
00:00
>> It's just used to run jobs on-demand.
00:00
>> We could schedule something out in advance,
00:00
>> like I said, by using a specified fixed time.
00:00
>> But we can also do it just using
00:00
the time that we just specified,
00:00
using that command where we're just specifying
00:00
your relative time three minutes from now.
00:00
But in this lesson, we covered the purpose of the at
00:00
command and how the atd daemon works.
00:00
We also talked about the at command syntax.
00:00
Then finally we submitted a job to the at queue
00:00
>> with the at command and looked at it in the queue.
00:00
>> Thank you so much for being here,
00:00
and I look forward to seeing you in the next lesson.
Up Next
Job Control
Kill Command (Demo)
Automate System Administration Tasks by Scheduling Jobs
Virtual Lab
Module 13 Overview: Linux Devices
Network Devices: Bluetooth, WiFi and Network Adapters