2

From the man pages it appears both do basically the same thing, why have both running on the system at the same time? From the wording in the man pages it looks like cron will repeatedly run programs at scheduled times while atd may run them only once, is this why?

1 Answer 1

4

The look like they are the same but there are some things at is a lot better at. Some differences:

cron

  • can be scheduled for repeated jobs (minute,hour,month,dayofmonth,dayofweek);
  • can be edited;
  • you set these in crontab or /etc/crontab

at

  • starts one time. To repeat it you need to start it again;
  • cannot be edited, after it started;
  • you can start this from commandline.
  • the most important ability of at command is the ability to operate in relative time terms.

Have a look at these examples and imagine how you'd do these with cron:

at 2pm + 1 week
at 2pm next week
at 0815 jan 24
at 8:15 jan 24
at now "+ 1 day"
at 5 pm friday
at '17:00 + 30minutes'

at now "+ 1day"
warning: commands will be executed using /bin/sh
at> date
at> <EOT>
job 3 at Wed Aug  9 23:39:00 2017
rinzwind@schijfwereld:~$ 

rinzwind@schijfwereld:~$ at 2pm + 1 week
warning: commands will be executed using /bin/sh
at> date
at> <EOT>
job 1 at Tue Aug 15 14:00:00 2017

$ at 0815 Jan 24
warning: commands will be executed using /bin/sh
at> date
at> <EOT>
job 2 at Wed Jan 24 08:15:00 2018

 at 5 pm FRIday
warning: commands will be executed using /bin/sh
at> date
at> <EOT>
job 4 at Fri Aug 11 17:00:00 2017
3
  • Your examples are nearly all incorrect. Don't just copy and paste from a website without reading what it says. softpanorama.org/Utilities/at.shtml
    – Ken Sharp
    Aug 8, 2017 at 21:16
  • 2
    @KenSharp "Your examples are nearly all incorrect" 1 (edit: 2) typo does not make them "nearly all'. and instead of downvoting why not edit the answer and make a comment about it?
    – Rinzwind
    Aug 8, 2017 at 21:41
  • This answer deserves upvote because it is useful, see the tooltip on the up button; correctness is not required. Many answers have a typo and are still useful.
    – Roland
    Oct 8, 2020 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.