Time syntax

When you use at, you can specify the time absolutely, like we did in the previous example, or relatively. An example of relative would be in 5 minutes or after 24 hours. This is often easier than checking the current time, adding your desired interval to it, and passing it to at. This works with the following syntax:

reader@ubuntu:~/scripts/chapter_14$ at now + 1 min
warning: commands will be executed using /bin/sh
at> touch /tmp/at-file
at> <EOT>
job 10 at Sun Nov 25 10:16:00 2018
reader@ubuntu:~/scripts/chapter_14$ date
Sun Nov 25 10:15:20 UTC 2018

You always need to specify relative to which time you want to add the minute, hour, or day. Fortunately, we can use now as a keyword for the current time. Do note that when dealing with minutes, at will always round to the nearest full minute. Besides minutes, the following are also valid (as found in man at):

  • Hours
  • Days
  • Weeks

You can even create more complex solutions, such as 4 pm three days from now. However, we feel like cron is better suited for these kinds of situations. With regards to at, the best use seems to be one-off jobs at a time that is near.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.182.159