suppress mail sent by batch or at command in linux

Posted on 2014-08-11
Last Modified: 2014-10-14
i have several batch or at jobs being scheduled every 3 minutes. Is it possible to suppress the mail being sent to the user who initially starts the job? I don't need to know anything about the job.

The user issues command:
  batch_the_command now + 3 minutes
Question by:penguins_rule
    LVL 3

    Expert Comment

    You should be able to add a  >/dev/null 2>&1 to the end of the command to prevent it from sending an email
    LVL 1

    Author Comment

    it still created the mail
    it did not show the job-id of the original command
    LVL 3

    Expert Comment

    if this is a crontab job you have to edit the job in the crontab via crontab -e. Otherwise, I'm not sure how this job runs or is scripted. It may be hard coded into the script.
    LVL 1

    Author Comment

    $ cat batch_the_command
    echo "This is the list of things to do for minute"
    The command and response:
    $ at -f /home/penguin/batch_the_command now
    job 2174 at 2014-08-11 16:46
    You have new mail
    $ mail
    & t
    Message  1:
    From penguin@localhost  Mon Aug 11 16:46:12 2014
    Return-Path: <penguin@localhost>
    X-Original-To: penguin
    Delivered-To: penguin@localhost
    Subject: Output from your job     2174
    To: penguin@localhost
    Date: Mon, 11 Aug 2014 16:46:12 -0400 (EDT)
    From: penguin@localhost (penguins_rule)
    Status: R
    This is the list of things to do for minute

    Open in new window

    LVL 1

    Author Comment

    How would I set it up in cron to run every three minutes and no email?
    LVL 37

    Accepted Solution

    Modify the at command line like this:

    $ at -M -f /home/penguin/batch_the_command now
    LVL 37

    Expert Comment

    by:Gerwin Jansen
    Some more details about at:

    gerwin@ubuntu:~$ at -?
    at: invalid option -- '?'
    Usage: at [-V] [-q x] [-f file] [-mMlbv] timespec ...
           at [-V] [-q x] [-f file] [-mMlbv] -t time
           at -c job ...
           atq [-V] [-q x]
           at [ -rd ] job ...
           atrm [-V] job ...

    Note the -M option

    From man at:

           If a job is submitted to a queue designated with an  uppercase  letter,
           the  job is treated as if it were submitted to batch at the time of the
           job.  Once the time is reached, the batch processing rules with respect
           to  load average apply.  If atq is given a specific queue, it will only
           show jobs pending in that queue.

           -m      Send mail to the user when the job has completed even if  there
                   was no output.

           -M      Never send mail to the user.

           -f file Reads the job from file rather than standard input.

           -t time run the job at time, given in the format [[CC]YY]MMDDhhmm[.ss]
    LVL 1

    Author Comment

    thank you for the man page on at command. I did not realize RedHat Linux and ubuntu had different switches. The -M switch did not show on my man page, but it still works.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. Please see for the updated article. It is avail…
    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now