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 ...
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 ...
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 ...
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 ...
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 (&...
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 ...
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 ...
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 ...
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 <<'...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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/...
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/...
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 ...
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 ...
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) (...
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 ...
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:
/...
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 ...
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.
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible