Linux Command at Examples

I often use cron jobs to run tasks on Linux. Cron is suitable for running recurring tasks. For one-time-only tasks, at is a better choice.

I needed to schedule some of our Linux servers to shutdown, so I wanted to use at. However, I have not used the command for a while and I couldn’t figure out the correct time(date) format to use. Finally, I turned to one of my favorite Linux(Unix) books – UNIX in a Nutshell and found some working examples. The following are the correct use of time(date) format.

at 1750 sep 17

at 5:50pm sep 17

at 4 am Sunday

at now + 6 hours

at midnight tomorrow

After you enter the at command, you will see an at prompt (at>). Enter the command(s) you want to run at the scheduled time. When you are done, press Ctrl + D. Here is an example to shutdown the server at 7:30am on 9/18.

# at 7:30am sep 18
at> shutdown -h now
at> <EOT>
job 2 at 2009-09-18 07:30

Note that <EOT> is not what I typed, it’s Ctrl + D.


This post may contain affiliated links. When you click on the link and purchase a product, we receive a small commision to keep us running. Thanks.


Be the first to comment

Leave a Reply