Our second scheduling tool that we're going to be
looking at on AlmaLinux is the at daemon,
where we can look at scheduling more irregular tasks.
Now to take a look at the at daemon, we need to make sure that it's installed.
Very often, it's not installed by default.
So on my AlmaLinux system,
I'm going to go through and use sudo and yum install ‑y,
just so it doesn't prompt me, and then the package name itself is just at.
So we can see there that it did need to install.
We've gone ahead and installed it,
and in doing so we would have added in an at.deny
file inside of our etc directory.
If we go through and list etc/at*, we can see the at.deny.
So just the same way as with cron,
the deny file is used to deny users access to the at command.
An allow file would be explicitly allowing only those
users listed in the allow file.
Now having installed the at package, it will not have started my service,
so I do need to go through and make sure that the service is running.
Obviously,
my users need the service running to be able to
have any of their jobs scheduled,
so I can go through and do a systemctl enable to make sure it starts on boot,
‑‑now to ensure that the service starts now, and the service name itself is
atd. The package is at; the service is atd. The command‑line utility we use is
also just called at, so I can go through and say at noon. Now we're already
after noon, so this is literally going to be the next noon that we come
across, so midday tomorrow.
I can then go through at the at prompt, specify the task that I want.
I can have multiple tasks.
I'll just keep it at this listing of the etc directory, just
as an example. To get outside of our editor and to ensure the
job is scheduled, we use Ctrl+D.
And we can see there that it's then scheduled to run the 30th of December at
midday. Atq will show me what jobs I have scheduled, and I can use atrm and the
job number to delete an entry. If I wanted to schedule something to happen on a
particular date, rather than, let's say, just the next time, we can go through
and schedule it using at.
So we can then go through and say December the 11th, 2022, and, again, go
through and put one or more commands. Again, I'm just going to list the etc,
but I could have multiple commands at my prompt.
I'm going to leave this to Ctrl+D, and we can see there that it's
going to be Sunday, December the 11th at 1:34.
We can also specify the exact time that we need it to happen, if that
was going to be necessary. If we want to look at the detail of this
job, if we had forgotten what we had put in,
we can go through and use atq to list our jobs, and then at
‑c to look at the detail of job number 4.
Now it might seem a lot,
but the at command exports the complete environment so the job executes in the
same environment that it was created in, but we can see then the actual job
being listed just towards the bottom of the screen.
If we don't want that to be executed,
of course, we can then go through and delete that job,
just the same way as we did before. Now listing my jobs will show I don't have any jobs scheduled with at.