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

                      How should I support this large drywall patch? Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How do I cover large gaps in drywall?How do I keep drywall around a patch from crumbling?Can I glue a second layer of drywall?How to patch long strip on drywall?Large drywall patch: how to avoid bulging seams?Drywall Mesh Patch vs. Bulge? To remove or not to remove?How to fix this drywall job?Prep drywall before backsplashWhat's the best way to fix this horrible drywall patch job?Drywall patching using 3M Patch Plus Primer

                      Lowndes Grove History Architecture References Navigation menu32°48′6″N 79°57′58″W / 32.80167°N 79.96611°W / 32.80167; -79.9661132°48′6″N 79°57′58″W / 32.80167°N 79.96611°W / 32.80167; -79.9661178002500"National Register Information System"Historic houses of South Carolina"Lowndes Grove""+32° 48' 6.00", −79° 57' 58.00""Lowndes Grove, Charleston County (260 St. Margaret St., Charleston)""Lowndes Grove"The Charleston ExpositionIt Happened in South Carolina"Lowndes Grove (House), Saint Margaret Street & Sixth Avenue, Charleston, Charleston County, SC(Photographs)"Plantations of the Carolina Low Countrye

                      random experiment with two different functions on unit interval Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)Random variable and probability space notionsRandom Walk with EdgesFinding functions where the increase over a random interval is Poisson distributedNumber of days until dayCan an observed event in fact be of zero probability?Unit random processmodels of coins and uniform distributionHow to get the number of successes given $n$ trials , probability $P$ and a random variable $X$Absorbing Markov chain in a computer. Is “almost every” turned into always convergence in computer executions?Stopped random walk is not uniformly integrable