Why does this 'at' command not print to the standard output?
Because at
does not execute commands in the context of your logged in user session. The idea is that you can schedule a command to run at an arbitrary time, then log out and the system will take care of running the command at the specified time.
Note that the manual page for at(1)
specifically says (my emphasis):
The user will be mailed standard error and standard output from his commands, if any. Mail will be sent using the command /usr/sbin/sendmail.
So you should be checking your local mail spool or, failing that, the local system mail logs. /var/spool/mail/$USER is probably a good place to start.
Also note that the "Started" and "Finished" originate from the outer script and in and of themselves have nothing to do with at
at all. You could take out them or the at
invocation and you'll get essentially the same result.
As @MichaelKjörling has explained it any output that's produced by your at
job will be captured and sent to you via email. If you don't have a running MTA - Mail Transfer Agent on your box then the email may be in limbo and you'll not know that at
is even attempting to do this.
A MTA, is a program such as sendmail
or postfix
that can "deliver" email to an appropriate destination. In this case it's going to deliver it to a mail queue (a file under the directory /var/spool/mail
) on your local system. Each user on the system can have a queue in this directory.
On my Fedora system if I start up sendmail
then local mail delivery can occur. I typically have it off though.
$ sudo service start sendmail
Now we can see that my mail queue for my user account saml
is empty:
$ ll /var/spool/mail/|grep saml
-rw-rw----. 1 saml mail 0 Jul 12 19:33 saml
So now we run the at
job:
$ at now + 1 minutes <<EOF
echo "Running"
EOF
job 96 at Fri Jul 12 19:38:00 2013
We can see that the job is waiting to run with atq
:
$ atq
96 Fri Jul 12 19:38:00 2013 a saml
Running it again after a couple of minutes we can see that the at
job is complete:
$ atq
$
Incidentally, with my MTA running I now get this message in my terminal:
You have new mail in /var/spool/mail/saml
So let's check:
$ ll /var/spool/mail/|grep saml
-rw-rw----. 1 saml mail 651 Jul 12 19:38 saml
Yup we've got mail, so let's check it out using mutt
:
$ mutt -f /var/spool/mail/saml
We have this in our mail queue's "inbox":
Let's check out this email:
And it worked.
I'm running Debian 8.1 (jessie)
You can have the the 'at' output go to a terminal by using tty.
$ tty
/dev/pts/1
$ at now + 1 min
warning: commands will be executed using /bin/sh
at> echo 'ZZZZZ' > /dev/pts/1
at> <EOT>
One minute later, and 'ZZZZZ' will show up in your terminal...