Learn GNU/Linux Commands (16): Schedule - sleep, at

sleep

sleep NUMBER[SUFFIX]...

Delay for a specified amount of time. The program "sleep" isn't for suspending the machine. Most implementations require NUMBER be an integer, some allow it to be a floating point number.

SUFFIX may be:

  • "s" for seconds (the default);
  • "m" for minutes;
  • "h" for hours;
  • "d" for days.
Given two or more arguments, "sleep" pause for the amount of time specified by the sum of their values.


Schedule with "sleep"

sleep NUMBER[SUFFIX]... && COMMAND

"&&" is the logical AND operator. Only when the previous value is true will the next command be executed. If "sleep" exits successfully, it returns TRUE (0 in the shell).

For example:

$ sleep 3s 2m 4h && poweroff
This line powers off the machine after 4 hours and 2 minutes and 3 seconds.


at

at TIME

Read commands from standard input which are to be executed at a later time, using /bin/sh.

Examples of TIME:

  • 12:3, 7:04, 7:04 PM, 8am
  • minight, noon, teatime (4pm)
  • September 24, Oct 5 4pm, noon Aug 2 2020, the date can also be MMDD[CC]YY, MM/DD/[CC]YY, DD.MM.[CC]YY or [CC]YY-MM-DD
  • now + 1 minute, now + 3 hours, now + 2 days

"at" options:

  • -f FILE: reads the job from FILE rather than standard input.
  • -l: list the user's pending jobs or all users' if the user is the superuser. The output format is: job number, date, hour, queue, and username. This is an alias for "atq".
  • -r JOB...: deletes jobs, identified by their job number. This is an alias for "atrm".
  • -d: same as "-r"

For example:

[texpion@com ~]$ at 22:30
warning: commands will be executed using /bin/sh
at> echo "Now is 22:30"
at> <EOT>
To end the input, press CTRL+D (end of file).


List Pending Jobs

atq

List the user's pending jobs or all users' if the user is the superuser. The output format is: job number, date, hour, queue, and username. Same as "at -l".


Delete Pending Jobs

atrm JOB...

Deletes JOB(S), identified by their job number. Same as "at -d" or "at -r".



Related

Comments

Popular

Intel 7th and 8th generation processor graphics driver for Windows 7/8/8.1

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part II - Fidelity

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part I - Lossless

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part IV - Decode

AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part III - Quality

OBS Studio settings for best quality (loseless) recording

Install VMAF on Fedora, CentOS/Red Hat (RHEL)