Linux 101 : The "at" command - Scheduling your jobs at the command line -



If our system doesn't have the "at" program installed, we can install it using the below command:


Then we could check if daemon "atd" is running using the below command:


We use "at" to run a command at a specific time.
Below is an example that prints a string at a "2 pm" on the "6th" of "January":


We use the <CTRL-D> key combination to close the interactive  mode for the "at" command.

Another timing example for the "at" command, could be "10 pm tomorrow"

Listing  scheduled "at" command:

To list our "at" scheduled jobs as "root" user, we use the below command:


Beside the following conventional timing schemes "HH:MM" or "MM/DD/YY" for example, we could use the less common ones, namely, "
midnight", "noon" or "teatime" which means "4pm".
We could also use "tomorrow" or "2pm + 1 day" to name just a few.

Deleting an "at" scheduled task:.

To remove one of our scheduled tasks, "Number 2", we use the below command:


Securing access to the "at" command:

To limit and control access to the "at" command, we use the "/etc/at.deny" and "/etc/at.allow" files.
Both these files contain a list of users.

If just the "/etc/at.deny" file is present on our system, then the users that appear in that file are not able to use the "at" command.

If just the "/etc/at.allow" file is present on our system, then the users that appear in that file are allowed to use the "at" command.

If neither of these files exist on our system, usually only the "root" user will have access to the "at" command.

If both "/etc/at.deny" and "/etc/at.allow" files are present on our system, the "/etc/at.allow" takes precedence over the "/etc/at.deny" file.

Comments

Leave as a comment:

Archive