0

I'm calling at jobs on AIX servers using this method:

/usr/bin/at now +1 minute << EOF chmod 700 /var/tmp/somescript.sh cd /var/tmp sh /var/tmp/somescript.sh > 2>&1 EOF

If ever some output is generated (because i.e. the script I'm calling doesn't exist), an email is sent to the default mail configured for cron jobs. I know this is default behavior and that is fine. However, if I want to change the MAILTO variable used, how can I do it using the method above ?

I tried adding [email protected] in the at script but that didn't work. The mail still went to the default address.

i.e.

/usr/bin/at now +1 minute << EOF [email protected] chmod 700 /var/tmp/somescript.sh cd /var/tmp sh /var/tmp/somescript.sh > 2>&1 EOF

The reason I'm using this method is because the jobs are created on a fly by another system, but this is irrelevant. I need to do it this way and can't edit the crontab.

1 Answer 1

1

Turns out there was an alias defined for root in /etc/mail/aliases and this is where it was coming from. There's no way for me to bypass it per-command with this on, as any mail sent to root's mailbox will automatically get forwarded to that alias.

4
  • if you have any control over the script, pipe its output to a logfile or to its own mail command
    – Jeff Schaller
    Jun 8, 2016 at 23:57
  • The issue was not to be able to send the output by mail, but rather that it wasn't being sent to root at all. Jun 9, 2016 at 0:01
  • if you capture all of the output then at won't have anything to mail (or you can send that redirected output in an email to someone else)
    – Jeff Schaller
    Jun 9, 2016 at 0:03
  • I also know that, but that was not the question. It works with a proper redirect, but if for whatever reason output is generated by mistake root will get it. It was a general question. Jun 9, 2016 at 0:10

Not the answer you're looking for? Browse other questions tagged .