2022-01-16 18:20:39 +00:00
|
|
|
---
|
|
|
|
title: "at"
|
2022-01-26 21:29:48 +00:00
|
|
|
tags: [ "Documentation", "Basics" ]
|
2022-01-16 18:20:39 +00:00
|
|
|
---
|
2021-05-15 14:41:45 +00:00
|
|
|
Install with:
|
|
|
|
|
|
|
|
> sudo apt install at
|
|
|
|
|
|
|
|
Enable the daemon service with:
|
|
|
|
|
|
|
|
> sudo systemctl enable --now atd
|
|
|
|
|
2020-01-02 00:04:35 +00:00
|
|
|
Then jobs can be specified with absolute time, such as:
|
|
|
|
|
|
|
|
> at 16:20
|
|
|
|
|
|
|
|
> at noon
|
|
|
|
|
|
|
|
> at midnight
|
|
|
|
|
|
|
|
> at teatime
|
|
|
|
|
2021-05-15 14:41:45 +00:00
|
|
|
Type in your command, e.g.:
|
|
|
|
|
|
|
|
> touch /tmp/myFile.txt
|
|
|
|
|
2020-01-02 00:04:35 +00:00
|
|
|
The jobs can also be specified relative to the current time:
|
|
|
|
|
|
|
|
> at now +15 minutes
|
|
|
|
|
|
|
|
Finally, accept the jobs with ^D.
|
|
|
|
|
|
|
|
# Managing `at` Jobs
|
|
|
|
|
|
|
|
Display a list of commands to run with:
|
|
|
|
|
|
|
|
> atq
|
|
|
|
|
|
|
|
`2 Sat Oct 20 16:00:00 2018 a roach-1`
|
|
|
|
|
|
|
|
This will print all pending IDs. Remove a job by the ID with:
|
|
|
|
|
|
|
|
> atrm 2
|
|
|
|
|
2020-01-10 04:19:29 +00:00
|
|
|
Check /var/spool/atd/
|
2023-04-13 04:06:54 +00:00
|
|
|
|
|
|
|
## Automation
|
|
|
|
|
|
|
|
Automatically add a job for later, by setting the date, then using echo for the command.
|
|
|
|
|
|
|
|
> t="$(date -d "2 minutes" +%R)"
|
|
|
|
|
|
|
|
> echo "fortune > ~/file" | at "$t"
|
|
|
|
|
|
|
|
> watch cat file
|
|
|
|
|
|
|
|
The `$t` here outputs the day in minutes, but you could also do `t="$(date -d "2 days" +%m/%d/%Y)"`.
|