Echoing 'at' command in terminal fails
-
09-07-2021 - |
Question
The following should print "hello" (or some reminder) on my Linux command line at 9:00 AM today:
$ at 9:00AM
warning: commands will be executed using /bin/sh
at> echo "hello"
at> <EOT>
However, at the specified time, nothing happens.
I have an empty etc/at.deny
and no /etc/at.allow
file, so there shouldn't be any problems with permissions to use the command. Also, writing a file at 9:00 AM works:
$ at 9:00AM
at> echo "hello" > /home/mart/hello.txt
at> <EOT>
$ cat /home/mart/hello.txt
hello
All jobs are shown as scheduled, I just can't get any output to the terminal window (I'm on Crunchbang Linux with Terminator). Why? Do I need to somehow specify the window for that output?
Thanks for any help!
Solution
at
runs commands from a daemon (atd
), which doesn't have access to your terminal. Thus, output from the script isn't going to appear in your terminal (unless you pipe to the right tty
in your command).
Instead, it does as man at
says:
The user will be mailed standard error and standard output from his commands, if any.
You may be able to access these reports using mail
if your machine is suitably configured.
If you want to have at
write to your terminal, you can try piping the output to write
, which writes a message to a user's TTY, or to wall
if you want to write to every terminal connected to the system.
OTHER TIPS
Okay, nneonneo's explanations led me to using wall
, which sends a message to all users. So setting oneself reminders in a terminal window can be done like this:
$ at 9:00AM
warning: commands will be executed using /bin/sh
at> echo "hello" | wall
at> <EOT>