Skip to main content
48 votes
Accepted

What is the difference between shutdown 18:00 and at 18:00 shutdown?

at 18:00 shutdown now creates an "at" job, which is performed at the specified time by the at daemon or perhaps the cron daemon, depending on your system. shutdown 18:00 starts a process in your ...
wurtel's user avatar
  • 16.5k
41 votes
Accepted

Making "at" work on macOS

Instead of updating at and the associated tools on macOS, lets try to make the default at on macOS work. The at manual on macOS says (my emphasis): IMPLEMENTATION NOTES Note that at is ...
Kusalananda's user avatar
  • 356k
24 votes

What is the difference between shutdown 18:00 and at 18:00 shutdown?

And now, the systemd answer. If you have CentOS 7, you have a systemd operating system and the answer is different. at 18:00 shutdown now still schedules via the at subsystem, but that shutdown ...
JdeBP's user avatar
  • 71.9k
22 votes
Accepted

Does `at` run a command later if the computer is off at the specified time?

at executes any command that should have been executed before when you wake up the computer, but may take a few minutes to do that. It doesn't even matter whether you gave it a specific date, as you ...
dessert's user avatar
  • 1,735
20 votes
Accepted

How does `at` know there will be a time change?

at attempts to parse the date and time given and runs it through mktime() with "Daylight Saving Time" set to -1 (not available, auto-detect). at source code: tm1.tm_isdst = -1; t = mktime (&...
frostschutz's user avatar
  • 52.1k
13 votes

at some time from now do something (and maybe also show result in console)

The correct at usage is at <timespec>, where <timespec> is the time specification. You can also use the -f option to specify the file containing the commands to execute. If -f and no ...
Marcelo's user avatar
  • 3,971
10 votes
Accepted

Temporarily declare a variable in Bash

You can't use at jobs because they run in a different context, and can't affect the current shell. But we can do something similar. This code will trigger an alarm signal, which we can catch and ...
Stephen Harris's user avatar
8 votes

Temporarily declare a variable in Bash

Sure: trap 'unset x; trap - USR1' USR1; { sleep 5m; kill -USR1 $$; } & This sets a trap on the USR1 signal, then (cheating with a semicolon to put it on one line) groups together the sleep and ...
Jeff Schaller's user avatar
  • 68.8k
8 votes

Pass the "at" command a string command instead of a path to a script whilst having it run immediately

Use a here-document to pass the script to run later on the command line: at now + 1 minute <<'END_AT' echo 'xyz' >> ~/testtest.txt END_AT The here-document is quoted (by using <<'...
Kusalananda's user avatar
  • 356k
7 votes

at some time from now do something (and maybe also show result in console)

Run the sleep in a subshell: (sleep 60; echo -e '\nhi') & Note: on Linux you can give the argument to sleep in seconds or with a suffix s/m/h/d (for seconds, minutes, hours, days). On BSD the ...
PiedPiper's user avatar
  • 1,004
7 votes

Schedule command to run at specific timestamp with systemd

systemd-run can schedule a command to be run at a specific time, as long as: the system is not powered down before that time, because it writes a transient timer & service file to /run, which is ...
Jeff Schaller's user avatar
  • 68.8k
6 votes
Accepted

at some time from now do something (and maybe also show result in console)

The "hi" stream is printed in my prompt (in the stdin) and not in my stdout No, it's not "printed in your stdin". If you pressed return, it wouldn't try to run hi as a command. It's just that the ...
Peter Cordes's user avatar
  • 6,690
6 votes
Accepted

Editing a job in At command

If you just need to fix a typo in the shell language itself, look for your job in directory /var/spool/cron/atjobs: # type -p date | at 1430 warning: commands will be executed using /bin/sh job 2 at ...
Jim L.'s user avatar
  • 8,785
5 votes
Accepted

How do I send postponed mail at a later time with Mutt?

I've discovered this script msmtpqueue mentioned by whereistejas on irc.freenode.net/neomutt Change your smtp command to msmtp-enqueue.sh. Emails will be queued instead of being sent. You can send ...
Jakub Jindra's user avatar
  • 1,522
5 votes

Remove jobs from at queue on a specified date

atq | awk '/Oct 29/ { print $1 }' This would print the job IDs of the jobs that contain the string Oct 29. What the awk code is doing is to match the given regular expression against each of the ...
Kusalananda's user avatar
  • 356k
5 votes
Accepted

Why does `at` not execute GUI applications?

GUI applications access the screen through a server. When you run them from the command line or the menu, the environment tells the application how to connect to the server. When you run an at ...
Eduardo Trápani's user avatar
5 votes

Why doesn't the following call to 'at' execute the bash script?

You are executing the script immediately, and scheduling its output for execution by at. Needless to say this fails. What I think you want is this #!/bin/bash echo "Done!" Consider you have ...
Chris Davies's user avatar
4 votes

atd, batch // Setting the load limiting factor

This builds upon the answer by Wesley B.. It applies if using systemctl. Instead of updating the service configuration directly, an override can be defined for it. It is better to do it this way ...
Asclepius's user avatar
  • 466
4 votes
Accepted

Why does atq not list jobs in either queue order, or chronological order?

atq lists jobs by listing the directory containing them, without sorting; so jobs end up listed in directory order. You will see the same order with sudo ls -lU /var/spool/at (or /var/spool/cron/...
Stephen Kitt's user avatar
4 votes
Accepted

specify a time interval in which to execute a certain script

You would do the scheduling with cron. The schedule would look like 0 8-19 * * * /path/to/script or 0 8,9,10,11,12,13,14,15,16,17,18,19 * * * /path/to/script and the script would look like #!/bin/...
Kusalananda's user avatar
  • 356k
4 votes

sshpass Solaris one liner passing a command

The remote shell does not seem to understand here-strings (<<<string). Here-strings are an extension to the POSIX standard and not understood by all shells. Instead, do the redirection ...
Kusalananda's user avatar
  • 356k
4 votes
Accepted

Running at command ran the script immediately

What am I doing wrong? You are invoking ./stop (or ./start). It's not at who runs the script immediately. It's you. By ./stop | at … you run ./stop and at simultaneously. This is how piping (|) works ...
Kamil Maciorowski's user avatar
4 votes
Accepted

at jobs: queue IDs and job files

Looking through the sources we find writefile(time_t runtimer, char queue) ... (void)snprintf(ppos, sizeof(atfile) - (ppos - atfile), "%c%5lx%8lx", queue, jobno, (unsigned long) (...
meuh's user avatar
  • 54.7k
4 votes
Accepted

Can't shutdown Linux guest OS with `at` command

"The user is already added to the sudo users group" - but you don't use sudo anywhere. You need to apply the administrative privileges somewhere by using the sudo command. For example: Use ...
Chris Davies's user avatar
3 votes

at job terminates almost immediately

So the crucial difference between starting the script directly and having at run it was: the lack of stdin in the latter case. So I can reproduce my script immediately shutting down by doing this: /...
Evgeniy Berezovsky's user avatar
3 votes
Accepted

Schedule a command to execute minutes later

You misunderstand what the -c option does. This option prints out the contents of the temporary file which is created by the at command when a new at job is created. Here is one way to create a ...
fpmurphy's user avatar
  • 4,756
3 votes
Accepted

Run scheduled at job now

You can use at -c and the job number to get the contents of the script and either pipe this to your shell or resubmit it then remove the job with atrm.
meuh's user avatar
  • 54.7k
3 votes
Accepted

At utility problem with echo "command" | at +[#][time-unit]

According to the at manual on Ubuntu, the format of the time specification can be on the form now + count time-units, where the time-units can be minutes, hours, days, or weeks This means that you ...
Kusalananda's user avatar
  • 356k
3 votes

how to specify precise date to atd

One concrete example: $ at 4pm + 5 days warning: commands will be executed using /bin/sh at> true at> <EOT> # ctrl+d job 1 at Thu May 4 16:00:00 2023 With a specific date/hour: $ at 4pm ...
Gilles Quénot's user avatar
3 votes

at some time from now do something (and maybe also show result in console)

That failed because you're piping the output of echo "hi", which is just hi to at, but at expects that it's input can be executed by the default system shell (usually bash, but sometimes something ...
Austin Hemmelgarn's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible