Why does cron require MTA for logging?2019 Community Moderator Electioncron logging but not working on some commandsHow can I disable UFW logging for a specific event?Why does this command work for logging script output?Is any extended logging available for cron jobs?Skip syslog/rsyslog logging of certain cron jobsCentOS 6 Cron Logging Without PostfixCron stopped logging to /var/log/cron.logWhy oracle linux system's /var/log/cron timezone different from system date?Why has cron stopped processing commands?Debian: Disable logging SSH sessions for an user

How to deal with a cynical class?

When two POV characters meet

Ban on all campaign finance?

Is all copper pipe pretty much the same?

Word for a person who has no opinion about whether god exists

Unreachable code, but reachable with exception

Can "semicircle" be used to refer to a part-circle that is not a exact half-circle?

what does the apostrophe mean in this notation?

If Invisibility ends because the original caster casts a non-concentration spell, does Invisibility also end on other targets of the original casting?

Latest web browser compatible with Windows 98

Does Linux have system calls to access all the features of the file systems it supports?

Welcoming 2019 Pi day: How to draw the letter π?

Examples of odd-dimensional manifolds that do not admit contact structure

Rejected in 4th interview round citing insufficient years of experience

Co-worker team leader wants to inject the crap software product of his friends into our development. What should I say to our common boss?

Sword in the Stone story where the sword was held in place by electromagnets

How to make readers know that my work has used a hidden constraint?

What does おとこえしや mean?

Good allowance savings plan?

Is a lawful good "antagonist" effective?

Is it illegal in Germany to take sick leave if you caused your own illness with food?

If the Captain's screens are out, does he switch seats with the co-pilot?

Making a sword in the stone, in a medieval world without magic

Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?



Why does cron require MTA for logging?



2019 Community Moderator Electioncron logging but not working on some commandsHow can I disable UFW logging for a specific event?Why does this command work for logging script output?Is any extended logging available for cron jobs?Skip syslog/rsyslog logging of certain cron jobsCentOS 6 Cron Logging Without PostfixCron stopped logging to /var/log/cron.logWhy oracle linux system's /var/log/cron timezone different from system date?Why has cron stopped processing commands?Debian: Disable logging SSH sessions for an user










10















Why does cron require MTA for logging? Is there any particular advantage to this? Why can't it create a log file like most other utilities?










share|improve this question
























  • Bit of a nitpick, but I'm pretty sure cron doesn't need a MTA; unless you're shipping cron mails off to a different host, all it would need is a MDA (mail delivery agent).

    – a CVn
    2 days ago















10















Why does cron require MTA for logging? Is there any particular advantage to this? Why can't it create a log file like most other utilities?










share|improve this question
























  • Bit of a nitpick, but I'm pretty sure cron doesn't need a MTA; unless you're shipping cron mails off to a different host, all it would need is a MDA (mail delivery agent).

    – a CVn
    2 days ago













10












10








10


1






Why does cron require MTA for logging? Is there any particular advantage to this? Why can't it create a log file like most other utilities?










share|improve this question
















Why does cron require MTA for logging? Is there any particular advantage to this? Why can't it create a log file like most other utilities?







networking cron logs email






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 10 at 19:39









Glorfindel

3051411




3051411










asked Mar 10 at 11:31









NikhilNikhil

367114




367114












  • Bit of a nitpick, but I'm pretty sure cron doesn't need a MTA; unless you're shipping cron mails off to a different host, all it would need is a MDA (mail delivery agent).

    – a CVn
    2 days ago

















  • Bit of a nitpick, but I'm pretty sure cron doesn't need a MTA; unless you're shipping cron mails off to a different host, all it would need is a MDA (mail delivery agent).

    – a CVn
    2 days ago
















Bit of a nitpick, but I'm pretty sure cron doesn't need a MTA; unless you're shipping cron mails off to a different host, all it would need is a MDA (mail delivery agent).

– a CVn
2 days ago





Bit of a nitpick, but I'm pretty sure cron doesn't need a MTA; unless you're shipping cron mails off to a different host, all it would need is a MDA (mail delivery agent).

– a CVn
2 days ago










2 Answers
2






active

oldest

votes


















19














Consider that the traditional "standard" way of logging data is syslog, where the metadata included in the messages are the "facility code" and the priority level. The facility code can be used to separate log streams from different services so that they can be split into different log files, etc. (even though the facility codes are somewhat limited in that they have fixed traditional meanings.)



What syslog doesn't have, is a way to separate messages for or from different users, and that's something that cron needs on a traditional multi-user system. It's no use collecting the messages from all users' cron jobs to a common log file where only the system administrator can see them. On the other hand, email naturally provides for sending messages to different users, so it's a logical choice here. The alternative would be for cron to do the work manually, and to create logfiles to each users' home directory, but a traditional multi-user Unix system would be assumed to have a working MTA, so implementing it in cron would have been mostly a futile exercise.



On modern systems, there might be alternative choices, of course.






share|improve this answer






























    12














    I assume that by "logging" you mean storing the actual output of jobs. The running of jobs is already logged in the cron log in /var/cron/log (the path may differ between systems). There is no MTA required for this log.



    A cron job is run as the user whose crontab the job is part of.



    In the general case, there is no guarantee that this user is able to create files on the system (a user may not be an interactive user), especially not under the /var hierarchy where logs are usually created. The safest way to notify the user of errors and other output from a job is therefore to collect these and send them by email to the user. This would also allow the user to set up email redirection for the account to be able to see e.g. errors in their preferred location.



    If the user wants to save the output of a job to file, they may do so with a simple redirection in the crontab:



    0 */2 * * * "$HOME/scripts/myscript" >"$HOME/logs/myscript.log" 2>&1


    This would run "$HOME/scripts/myscript" every second hour, on the hour, and would save all output to "$HOME/logs/myscript.log". No emails would be created by running this job as all output is redirected. Without the 2>&1, error messages would still be sent by email.



    This allows the user to choose where the output goes.






    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
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f505453%2fwhy-does-cron-require-mta-for-logging%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      19














      Consider that the traditional "standard" way of logging data is syslog, where the metadata included in the messages are the "facility code" and the priority level. The facility code can be used to separate log streams from different services so that they can be split into different log files, etc. (even though the facility codes are somewhat limited in that they have fixed traditional meanings.)



      What syslog doesn't have, is a way to separate messages for or from different users, and that's something that cron needs on a traditional multi-user system. It's no use collecting the messages from all users' cron jobs to a common log file where only the system administrator can see them. On the other hand, email naturally provides for sending messages to different users, so it's a logical choice here. The alternative would be for cron to do the work manually, and to create logfiles to each users' home directory, but a traditional multi-user Unix system would be assumed to have a working MTA, so implementing it in cron would have been mostly a futile exercise.



      On modern systems, there might be alternative choices, of course.






      share|improve this answer



























        19














        Consider that the traditional "standard" way of logging data is syslog, where the metadata included in the messages are the "facility code" and the priority level. The facility code can be used to separate log streams from different services so that they can be split into different log files, etc. (even though the facility codes are somewhat limited in that they have fixed traditional meanings.)



        What syslog doesn't have, is a way to separate messages for or from different users, and that's something that cron needs on a traditional multi-user system. It's no use collecting the messages from all users' cron jobs to a common log file where only the system administrator can see them. On the other hand, email naturally provides for sending messages to different users, so it's a logical choice here. The alternative would be for cron to do the work manually, and to create logfiles to each users' home directory, but a traditional multi-user Unix system would be assumed to have a working MTA, so implementing it in cron would have been mostly a futile exercise.



        On modern systems, there might be alternative choices, of course.






        share|improve this answer

























          19












          19








          19







          Consider that the traditional "standard" way of logging data is syslog, where the metadata included in the messages are the "facility code" and the priority level. The facility code can be used to separate log streams from different services so that they can be split into different log files, etc. (even though the facility codes are somewhat limited in that they have fixed traditional meanings.)



          What syslog doesn't have, is a way to separate messages for or from different users, and that's something that cron needs on a traditional multi-user system. It's no use collecting the messages from all users' cron jobs to a common log file where only the system administrator can see them. On the other hand, email naturally provides for sending messages to different users, so it's a logical choice here. The alternative would be for cron to do the work manually, and to create logfiles to each users' home directory, but a traditional multi-user Unix system would be assumed to have a working MTA, so implementing it in cron would have been mostly a futile exercise.



          On modern systems, there might be alternative choices, of course.






          share|improve this answer













          Consider that the traditional "standard" way of logging data is syslog, where the metadata included in the messages are the "facility code" and the priority level. The facility code can be used to separate log streams from different services so that they can be split into different log files, etc. (even though the facility codes are somewhat limited in that they have fixed traditional meanings.)



          What syslog doesn't have, is a way to separate messages for or from different users, and that's something that cron needs on a traditional multi-user system. It's no use collecting the messages from all users' cron jobs to a common log file where only the system administrator can see them. On the other hand, email naturally provides for sending messages to different users, so it's a logical choice here. The alternative would be for cron to do the work manually, and to create logfiles to each users' home directory, but a traditional multi-user Unix system would be assumed to have a working MTA, so implementing it in cron would have been mostly a futile exercise.



          On modern systems, there might be alternative choices, of course.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 10 at 12:02









          ilkkachuilkkachu

          61.2k1099175




          61.2k1099175























              12














              I assume that by "logging" you mean storing the actual output of jobs. The running of jobs is already logged in the cron log in /var/cron/log (the path may differ between systems). There is no MTA required for this log.



              A cron job is run as the user whose crontab the job is part of.



              In the general case, there is no guarantee that this user is able to create files on the system (a user may not be an interactive user), especially not under the /var hierarchy where logs are usually created. The safest way to notify the user of errors and other output from a job is therefore to collect these and send them by email to the user. This would also allow the user to set up email redirection for the account to be able to see e.g. errors in their preferred location.



              If the user wants to save the output of a job to file, they may do so with a simple redirection in the crontab:



              0 */2 * * * "$HOME/scripts/myscript" >"$HOME/logs/myscript.log" 2>&1


              This would run "$HOME/scripts/myscript" every second hour, on the hour, and would save all output to "$HOME/logs/myscript.log". No emails would be created by running this job as all output is redirected. Without the 2>&1, error messages would still be sent by email.



              This allows the user to choose where the output goes.






              share|improve this answer





























                12














                I assume that by "logging" you mean storing the actual output of jobs. The running of jobs is already logged in the cron log in /var/cron/log (the path may differ between systems). There is no MTA required for this log.



                A cron job is run as the user whose crontab the job is part of.



                In the general case, there is no guarantee that this user is able to create files on the system (a user may not be an interactive user), especially not under the /var hierarchy where logs are usually created. The safest way to notify the user of errors and other output from a job is therefore to collect these and send them by email to the user. This would also allow the user to set up email redirection for the account to be able to see e.g. errors in their preferred location.



                If the user wants to save the output of a job to file, they may do so with a simple redirection in the crontab:



                0 */2 * * * "$HOME/scripts/myscript" >"$HOME/logs/myscript.log" 2>&1


                This would run "$HOME/scripts/myscript" every second hour, on the hour, and would save all output to "$HOME/logs/myscript.log". No emails would be created by running this job as all output is redirected. Without the 2>&1, error messages would still be sent by email.



                This allows the user to choose where the output goes.






                share|improve this answer



























                  12












                  12








                  12







                  I assume that by "logging" you mean storing the actual output of jobs. The running of jobs is already logged in the cron log in /var/cron/log (the path may differ between systems). There is no MTA required for this log.



                  A cron job is run as the user whose crontab the job is part of.



                  In the general case, there is no guarantee that this user is able to create files on the system (a user may not be an interactive user), especially not under the /var hierarchy where logs are usually created. The safest way to notify the user of errors and other output from a job is therefore to collect these and send them by email to the user. This would also allow the user to set up email redirection for the account to be able to see e.g. errors in their preferred location.



                  If the user wants to save the output of a job to file, they may do so with a simple redirection in the crontab:



                  0 */2 * * * "$HOME/scripts/myscript" >"$HOME/logs/myscript.log" 2>&1


                  This would run "$HOME/scripts/myscript" every second hour, on the hour, and would save all output to "$HOME/logs/myscript.log". No emails would be created by running this job as all output is redirected. Without the 2>&1, error messages would still be sent by email.



                  This allows the user to choose where the output goes.






                  share|improve this answer















                  I assume that by "logging" you mean storing the actual output of jobs. The running of jobs is already logged in the cron log in /var/cron/log (the path may differ between systems). There is no MTA required for this log.



                  A cron job is run as the user whose crontab the job is part of.



                  In the general case, there is no guarantee that this user is able to create files on the system (a user may not be an interactive user), especially not under the /var hierarchy where logs are usually created. The safest way to notify the user of errors and other output from a job is therefore to collect these and send them by email to the user. This would also allow the user to set up email redirection for the account to be able to see e.g. errors in their preferred location.



                  If the user wants to save the output of a job to file, they may do so with a simple redirection in the crontab:



                  0 */2 * * * "$HOME/scripts/myscript" >"$HOME/logs/myscript.log" 2>&1


                  This would run "$HOME/scripts/myscript" every second hour, on the hour, and would save all output to "$HOME/logs/myscript.log". No emails would be created by running this job as all output is redirected. Without the 2>&1, error messages would still be sent by email.



                  This allows the user to choose where the output goes.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 10 at 12:38

























                  answered Mar 10 at 11:55









                  KusalanandaKusalananda

                  135k17255422




                  135k17255422



























                      draft saved

                      draft discarded
















































                      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%2f505453%2fwhy-does-cron-require-mta-for-logging%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

                      Solar Wings Breeze Design and development Specifications (Breeze) References Navigation menu1368-485X"Hang glider: Breeze (Solar Wings)"e

                      Kathakali Contents Etymology and nomenclature History Repertoire Songs and musical instruments Traditional plays Styles: Sampradayam Training centers and awards Relationship to other dance forms See also Notes References External links Navigation menueThe Illustrated Encyclopedia of Hinduism: A-MSouth Asian Folklore: An EncyclopediaRoutledge International Encyclopedia of Women: Global Women's Issues and KnowledgeKathakali Dance-drama: Where Gods and Demons Come to PlayKathakali Dance-drama: Where Gods and Demons Come to PlayKathakali Dance-drama: Where Gods and Demons Come to Play10.1353/atj.2005.0004The Illustrated Encyclopedia of Hinduism: A-MEncyclopedia of HinduismKathakali Dance-drama: Where Gods and Demons Come to PlaySonic Liturgy: Ritual and Music in Hindu Tradition"The Mirror of Gesture"Kathakali Dance-drama: Where Gods and Demons Come to Play"Kathakali"Indian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceMedieval Indian Literature: An AnthologyThe Oxford Companion to Indian TheatreSouth Asian Folklore: An Encyclopedia : Afghanistan, Bangladesh, India, Nepal, Pakistan, Sri LankaThe Rise of Performance Studies: Rethinking Richard Schechner's Broad SpectrumIndian Theatre: Traditions of PerformanceModern Asian Theatre and Performance 1900-2000Critical Theory and PerformanceBetween Theater and AnthropologyKathakali603847011Indian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceBetween Theater and AnthropologyBetween Theater and AnthropologyNambeesan Smaraka AwardsArchivedThe Cambridge Guide to TheatreRoutledge International Encyclopedia of Women: Global Women's Issues and KnowledgeThe Garland Encyclopedia of World Music: South Asia : the Indian subcontinentThe Ethos of Noh: Actors and Their Art10.2307/1145740By Means of Performance: Intercultural Studies of Theatre and Ritual10.1017/s204912550000100xReconceiving the Renaissance: A Critical ReaderPerformance TheoryListening to Theatre: The Aural Dimension of Beijing Opera10.2307/1146013Kathakali: The Art of the Non-WorldlyOn KathakaliKathakali, the dance theatreThe Kathakali Complex: Performance & StructureKathakali Dance-Drama: Where Gods and Demons Come to Play10.1093/obo/9780195399318-0071Drama and Ritual of Early Hinduism"In the Shadow of Hollywood Orientalism: Authentic East Indian Dancing"10.1080/08949460490274013Sanskrit Play Production in Ancient IndiaIndian Music: History and StructureBharata, the Nāṭyaśāstra233639306Table of Contents2238067286469807Dance In Indian Painting10.2307/32047833204783Kathakali Dance-Theatre: A Visual Narrative of Sacred Indian MimeIndian Classical Dance: The Renaissance and BeyondKathakali: an indigenous art-form of Keralaeee

                      Method to test if a number is a perfect power? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)Detecting perfect squares faster than by extracting square rooteffective way to get the integer sequence A181392 from oeisA rarely mentioned fact about perfect powersHow many numbers such $n$ are there that $n<100,lfloorsqrtn rfloor mid n$Check perfect squareness by modulo division against multiple basesFor what pair of integers $(a,b)$ is $3^a + 7^b$ a perfect square.Do there exist any positive integers $n$ such that $lfloore^nrfloor$ is a perfect power? What is the probability that one exists?finding perfect power factors of an integerProve that the sequence contains a perfect square for any natural number $m $ in the domain of $f$ .Counting Perfect Powers