Prevent cronjob's from writing to /var/mail/$USER?Use /etc/aliases for outgoing mail relayed by postfix with...

How to befriend someone who doesn't like to talk?

Why do I seem to lose data using this bash pipe construction?

Why is my power MOSFET heating up when on?

Was planting UN flag on Moon ever discussed?

Selecting by attribute using Python and a list

Can I use 220 V outlets on a 15 ampere breaker and wire it up as 110 V?

Was self-modifying code possible using BASIC?

Am I allowed to determine tenets of my contract as a warlock?

Playing a trill with grace note ending

What is the theme of analysis?

Course development: can I pay someone to make slides for the course?

How much web presence should I have?

A life of PhD: is it feasible?

Is there a better way to do partial sums of array items in JavaScript?

Forgot passport for Alaska cruise (Anchorage to Vancouver)

How can you estimate a spike story?

Is it advisable to add a location heads-up when a scene changes in a novel?

How do I type a hyphen in iOS 12?

What did the 8086 (and 8088) do upon encountering an illegal instruction?

Mathematica 12 has gotten worse at solving simple equations?

Is all-caps blackletter no longer taboo?

Lowest Magnitude Eigenvalues of Large Sparse Matrices

How to change the headfont of newtheorem environments to match komascript font?

C++ logging library



Prevent cronjob's from writing to /var/mail/$USER?


Use /etc/aliases for outgoing mail relayed by postfix with local domainHow do I completely silence a cronjob to /dev/null/?Logrotate does not work for httpd servicecronjob does not execute when not logged inCron only occasionally sends e-mail on output and errorsI lost my mail spoolWhat can be reason for getting “execute permission denied” in cronjob in UNIX?Cron.d not running (rsnapshot)CRON (no tty): Delete message with specific “Message-Id”cron jobs printing to /dev/stdout






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















In macOS, cronjobs configured with crontab have the command output and/or error messages (if the cron doesn't succeed) written to the /var/mail/$USER file. Can this be prevented? I've tried:



* * * * *      /sbin/ping -c1 website.com ... 2>&1 >/dev/null


Whether it succeeds or fails to reach the domain, the ping output is saved to the mail file...










share|improve this question









New contributor



user357226 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • You could state your shell too.

    – Tomasz
    1 hour ago











  • Huh? I'm not sure what you mean.

    – user357226
    1 hour ago











  • echo "$SHELL" should help, I guess.

    – Tomasz
    1 hour ago











  • My shell produces "/bin/bash". Can you give a small example of how this helps? I don't follow, sorry.

    – user357226
    1 hour ago











  • I'm don't know many shell, nor do I know the differences. In this case I guess this shouldn't make much difference unless you use a very exotic one. But it's a good habit to state what software is involved. Your question is about the shell after all!

    – Tomasz
    1 hour ago


















0















In macOS, cronjobs configured with crontab have the command output and/or error messages (if the cron doesn't succeed) written to the /var/mail/$USER file. Can this be prevented? I've tried:



* * * * *      /sbin/ping -c1 website.com ... 2>&1 >/dev/null


Whether it succeeds or fails to reach the domain, the ping output is saved to the mail file...










share|improve this question









New contributor



user357226 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • You could state your shell too.

    – Tomasz
    1 hour ago











  • Huh? I'm not sure what you mean.

    – user357226
    1 hour ago











  • echo "$SHELL" should help, I guess.

    – Tomasz
    1 hour ago











  • My shell produces "/bin/bash". Can you give a small example of how this helps? I don't follow, sorry.

    – user357226
    1 hour ago











  • I'm don't know many shell, nor do I know the differences. In this case I guess this shouldn't make much difference unless you use a very exotic one. But it's a good habit to state what software is involved. Your question is about the shell after all!

    – Tomasz
    1 hour ago














0












0








0








In macOS, cronjobs configured with crontab have the command output and/or error messages (if the cron doesn't succeed) written to the /var/mail/$USER file. Can this be prevented? I've tried:



* * * * *      /sbin/ping -c1 website.com ... 2>&1 >/dev/null


Whether it succeeds or fails to reach the domain, the ping output is saved to the mail file...










share|improve this question









New contributor



user357226 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











In macOS, cronjobs configured with crontab have the command output and/or error messages (if the cron doesn't succeed) written to the /var/mail/$USER file. Can this be prevented? I've tried:



* * * * *      /sbin/ping -c1 website.com ... 2>&1 >/dev/null


Whether it succeeds or fails to reach the domain, the ping output is saved to the mail file...







bash osx cron ping






share|improve this question









New contributor



user357226 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



user357226 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 1 hour ago









Tomasz

10.6k73473




10.6k73473






New contributor



user357226 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 1 hour ago









user357226user357226

1




1




New contributor



user357226 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




user357226 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • You could state your shell too.

    – Tomasz
    1 hour ago











  • Huh? I'm not sure what you mean.

    – user357226
    1 hour ago











  • echo "$SHELL" should help, I guess.

    – Tomasz
    1 hour ago











  • My shell produces "/bin/bash". Can you give a small example of how this helps? I don't follow, sorry.

    – user357226
    1 hour ago











  • I'm don't know many shell, nor do I know the differences. In this case I guess this shouldn't make much difference unless you use a very exotic one. But it's a good habit to state what software is involved. Your question is about the shell after all!

    – Tomasz
    1 hour ago



















  • You could state your shell too.

    – Tomasz
    1 hour ago











  • Huh? I'm not sure what you mean.

    – user357226
    1 hour ago











  • echo "$SHELL" should help, I guess.

    – Tomasz
    1 hour ago











  • My shell produces "/bin/bash". Can you give a small example of how this helps? I don't follow, sorry.

    – user357226
    1 hour ago











  • I'm don't know many shell, nor do I know the differences. In this case I guess this shouldn't make much difference unless you use a very exotic one. But it's a good habit to state what software is involved. Your question is about the shell after all!

    – Tomasz
    1 hour ago

















You could state your shell too.

– Tomasz
1 hour ago





You could state your shell too.

– Tomasz
1 hour ago













Huh? I'm not sure what you mean.

– user357226
1 hour ago





Huh? I'm not sure what you mean.

– user357226
1 hour ago













echo "$SHELL" should help, I guess.

– Tomasz
1 hour ago





echo "$SHELL" should help, I guess.

– Tomasz
1 hour ago













My shell produces "/bin/bash". Can you give a small example of how this helps? I don't follow, sorry.

– user357226
1 hour ago





My shell produces "/bin/bash". Can you give a small example of how this helps? I don't follow, sorry.

– user357226
1 hour ago













I'm don't know many shell, nor do I know the differences. In this case I guess this shouldn't make much difference unless you use a very exotic one. But it's a good habit to state what software is involved. Your question is about the shell after all!

– Tomasz
1 hour ago





I'm don't know many shell, nor do I know the differences. In this case I guess this shouldn't make much difference unless you use a very exotic one. But it's a good habit to state what software is involved. Your question is about the shell after all!

– Tomasz
1 hour ago










1 Answer
1






active

oldest

votes


















0














2>&1 >/dev/null doesn't redirect both to /dev/null. It only redirects stdout, as the redirections are performed left to right. So it should only send sterr to mail. The right order is >/dev/null 2>&1. First stdout is redirected to /dev/null and then stderr to the same location (&1).



(I can't find out why it goes to mail by both failure and success in your case. I'm not a Mac user, so can't look around this. This seems unusual to me though - a Debian user.)






share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    user357226 is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f524111%2fprevent-cronjobs-from-writing-to-var-mail-user%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    2>&1 >/dev/null doesn't redirect both to /dev/null. It only redirects stdout, as the redirections are performed left to right. So it should only send sterr to mail. The right order is >/dev/null 2>&1. First stdout is redirected to /dev/null and then stderr to the same location (&1).



    (I can't find out why it goes to mail by both failure and success in your case. I'm not a Mac user, so can't look around this. This seems unusual to me though - a Debian user.)






    share|improve this answer






























      0














      2>&1 >/dev/null doesn't redirect both to /dev/null. It only redirects stdout, as the redirections are performed left to right. So it should only send sterr to mail. The right order is >/dev/null 2>&1. First stdout is redirected to /dev/null and then stderr to the same location (&1).



      (I can't find out why it goes to mail by both failure and success in your case. I'm not a Mac user, so can't look around this. This seems unusual to me though - a Debian user.)






      share|improve this answer




























        0












        0








        0







        2>&1 >/dev/null doesn't redirect both to /dev/null. It only redirects stdout, as the redirections are performed left to right. So it should only send sterr to mail. The right order is >/dev/null 2>&1. First stdout is redirected to /dev/null and then stderr to the same location (&1).



        (I can't find out why it goes to mail by both failure and success in your case. I'm not a Mac user, so can't look around this. This seems unusual to me though - a Debian user.)






        share|improve this answer















        2>&1 >/dev/null doesn't redirect both to /dev/null. It only redirects stdout, as the redirections are performed left to right. So it should only send sterr to mail. The right order is >/dev/null 2>&1. First stdout is redirected to /dev/null and then stderr to the same location (&1).



        (I can't find out why it goes to mail by both failure and success in your case. I'm not a Mac user, so can't look around this. This seems unusual to me though - a Debian user.)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 1 hour ago

























        answered 1 hour ago









        TomaszTomasz

        10.6k73473




        10.6k73473






















            user357226 is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            user357226 is a new contributor. Be nice, and check out our Code of Conduct.













            user357226 is a new contributor. Be nice, and check out our Code of Conduct.












            user357226 is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f524111%2fprevent-cronjobs-from-writing-to-var-mail-user%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...