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 MAILTO=myaddress@mydomain.com 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 MAILTO=myaddress@mydomain.com 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.

closed as off-topic by Archemar, MelBurslan, user34720, Jeff Schaller, cuonglm Jun 9 '16 at 1:18

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Archemar, MelBurslan, Community, Jeff Schaller, cuonglm
If this question can be reworded to fit the rules in the help center, please edit the question.

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.

  • if you have any control over the script, pipe its output to a logfile or to its own mail command – Jeff Schaller Jun 8 '16 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. – Yanick Girouard Jun 9 '16 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 '16 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. – Yanick Girouard Jun 9 '16 at 0:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.