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
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
add a comment |
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
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
add a comment |
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
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
networking cron logs email
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 10 at 12:02
ilkkachuilkkachu
61.2k1099175
61.2k1099175
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited Mar 10 at 12:38
answered Mar 10 at 11:55
KusalanandaKusalananda
135k17255422
135k17255422
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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