at
Install with:
1sudo apt install at
Enable the daemon service with:
1sudo systemctl enable --now atd
Then jobs can be specified with absolute time, such as:
1at 16:20
1at noon
1at midnight
1at teatime
Type in your command, e.g.:
1touch /tmp/$FILE.txt
The jobs can also be specified relative to the current time:
1at now +15 minutes
Finally, accept the jobs with ^D.
Managing at
Jobs
Display a list of commands to run with:
1atq
2 Sat Oct 20 16:00:00 2018 a roach-1
This will print all pending IDs. Remove a job by the ID with:
1atrm 2
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.
1t="$(date -d "2 minutes" +%R)"
2echo "fortune > ~/$FILE" | at "$t"
3watch cat $FILE
The $t
here outputs the day in minutes, but you could also do t="$(date -d "2 days" +%m/%d/%Y)"
.