forked from andonome/lk
change formatting
input examples are now given as ```bash input $ARG1 ``` While outputs use md's '> ' sign as a quote.
This commit is contained in:
54
basics/at.md
54
basics/at.md
@@ -4,29 +4,45 @@ tags: [ "Documentation", "Basics" ]
|
||||
---
|
||||
Install with:
|
||||
|
||||
> sudo apt install at
|
||||
```bash
|
||||
sudo apt install at
|
||||
```
|
||||
|
||||
Enable the daemon service with:
|
||||
|
||||
> sudo systemctl enable --now atd
|
||||
```bash
|
||||
sudo systemctl enable --now atd
|
||||
```
|
||||
|
||||
Then jobs can be specified with absolute time, such as:
|
||||
|
||||
> at 16:20
|
||||
```bash
|
||||
at 16:20
|
||||
```
|
||||
|
||||
> at noon
|
||||
```bash
|
||||
at noon
|
||||
```
|
||||
|
||||
> at midnight
|
||||
```bash
|
||||
at midnight
|
||||
```
|
||||
|
||||
> at teatime
|
||||
```bash
|
||||
at teatime
|
||||
```
|
||||
|
||||
Type in your command, e.g.:
|
||||
|
||||
> touch /tmp/myFile.txt
|
||||
```bash
|
||||
touch /tmp/$FILE.txt
|
||||
```
|
||||
|
||||
The jobs can also be specified relative to the current time:
|
||||
|
||||
> at now +15 minutes
|
||||
```bash
|
||||
at now +15 minutes
|
||||
```
|
||||
|
||||
Finally, accept the jobs with ^D.
|
||||
|
||||
@@ -34,24 +50,28 @@ Finally, accept the jobs with ^D.
|
||||
|
||||
Display a list of commands to run with:
|
||||
|
||||
> atq
|
||||
```bash
|
||||
atq
|
||||
```
|
||||
|
||||
`2 Sat Oct 20 16:00:00 2018 a roach-1`
|
||||
> 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
|
||||
```bash
|
||||
atrm 2
|
||||
```
|
||||
|
||||
Check /var/spool/atd/
|
||||
Check `/var/spool/atd/` to see the jobs.
|
||||
|
||||
## 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
|
||||
```bash
|
||||
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)"`.
|
||||
|
Reference in New Issue
Block a user