At

From Freephile Wiki

One-time Jobs

You can certainly use cron to run one-time jobs, but that would be more effort than it's worth, since cron is designed for repeating jobs. The at command is the correct tool for this job.

Using the at command, you can specify a job to be run at some time in the future. The most common thing I do with at is schedule a reboot. Of course if you just want to reboot the machine at 10pm, you can do /sbin/shutdown -r 22:00 "rebooting at 10:00 P.M." & Do this in a screen session to ensure that the current shell does not need to be intact, but I think backgrounding the process with & takes care of that (depending on your shell environment). Anyway, the shutdown command is not as flexible with date and time arguments as the at command. With at, you can specify at 8am tomorrow. Invoking this command launches an interactive shell which you then enter the command to be executed. E.g. shutdown -r now. Finally, you exit the interactive shell with Ctrl+d. atq will list the jobs in the queue. at -c 1 will 'cat' (display) details of job 1 atrm 1 will remove job #1 from the queue.

Since at reads from STDIN, you can just pipe the command to it rather than using the interactive shell: echo "ls -al" | at now + 1 minute Note that since at runs non-interactively with a different shell, you won't actually see the results of the 'ls' command.

echo "shutdown -r now" | at 8am tomorrow
echo "shutdown -r now" | at midnight 2017-02-25
# show the queue
atq
# show details of job 1
at -c 1
# cancel / remove job 1
atrm 1