Assuming you are using Thomas Koenig's at on a glibc (Linux) system (now maintained by Jose Calhariz), it's possible but not documented clearly, from at(1):
If the file /var/run/utmp is not available or corrupted, or if the user
is not logged on at the time at is invoked, the mail is sent to the
userid found in the environment variable LOGNAME. If that is undefined
or empty, the current userid is assumed.
The way at works is to construct a job file which atd uses, the first three lines of which are:
#!/bin/sh
# atrun uid=100 gid=100
# mail youruser 1
where uid=100, gid=100 and youruser are determined programmatically when the job is being created. The logic for determining the username is:
- call
getlogin()
- if that's NULL call
getenv("LOGNAME")
- check the name exists by calling
getpwnam()
- if that's NULL call
getpwuid(real_uid)
- if that's NULL throw all of the toys out of the pram
So, how can we convince getlogin() to return NULL in order to use the LOGNAME variable? One way is to arrange for stdin to not be a terminal (this is why I assume glibc, getlogin() behaves differently across systems).
To do this from bash:
LOGNAME=backup at 19:52 -m <<< uptime
echo uptime | LOGNAME=backup at 19:52 -m
The point is to use redirection to present the command(s) on stdin for at to run. (at also performs a reopening of stdin if you use its -f option, though too late to be of use here.) You can instead save your command to a file, or with bash to save creating a file:
LOGNAME=backup at 19:52 -m -f <( echo uptime ) 0<&-
(0<&- closes stdin, < /dev/null will also work)
If your terminal (or screen or tmux) disregards utmp (by configuration, or though permissions or helper problems), you can even just set LOGNAME and just use at as normal since getlogin() will fail. You can tell if this is the case by finding your terminal using tty and then checking w to see if you're properly logged in on that tty, or try perl -E 'say getlogin()||"not-in-utmp";' .
(Just to be clear, LOGNAME can only be a local username, if you need an email to go elsewhere you will need to use aliases/.forward/procmail etc.)