Possibility to disable or hide CRON notification about starting one specific process












2














I was wondering if it is possible to having multiple cron jobs in crontab active, but only one of them starts each minute. The problem here is I wish to keep log of all others jobs informations with the exception of this only one.



Oct 25 14:50:01 dtest CRON[942]: (root) CMD (/usr/bin/python2.7 check.py > /dev/null 2>&1)


Currently I am getting flooded with all those lines, which made me curious if cron is able to supress a log entry for selected processes?










share|improve this question
























  • I don't think cron is designed to be configured to not log event triggers for only one specific event. You can either log, or not. If you want to tail the log and eschew those entries, you can tail -f logfile | grep -v 'python2.7 check.py'.
    – DopeGhoti
    Oct 25 at 19:05






  • 1




    Just was curious if there is actually any possibility to hide specific entry. Thank You for clarification
    – RedS
    Oct 25 at 19:15










  • How are you being flooded? Email? Syslog? Something else?
    – roaima
    Oct 25 at 19:54
















2














I was wondering if it is possible to having multiple cron jobs in crontab active, but only one of them starts each minute. The problem here is I wish to keep log of all others jobs informations with the exception of this only one.



Oct 25 14:50:01 dtest CRON[942]: (root) CMD (/usr/bin/python2.7 check.py > /dev/null 2>&1)


Currently I am getting flooded with all those lines, which made me curious if cron is able to supress a log entry for selected processes?










share|improve this question
























  • I don't think cron is designed to be configured to not log event triggers for only one specific event. You can either log, or not. If you want to tail the log and eschew those entries, you can tail -f logfile | grep -v 'python2.7 check.py'.
    – DopeGhoti
    Oct 25 at 19:05






  • 1




    Just was curious if there is actually any possibility to hide specific entry. Thank You for clarification
    – RedS
    Oct 25 at 19:15










  • How are you being flooded? Email? Syslog? Something else?
    – roaima
    Oct 25 at 19:54














2












2








2







I was wondering if it is possible to having multiple cron jobs in crontab active, but only one of them starts each minute. The problem here is I wish to keep log of all others jobs informations with the exception of this only one.



Oct 25 14:50:01 dtest CRON[942]: (root) CMD (/usr/bin/python2.7 check.py > /dev/null 2>&1)


Currently I am getting flooded with all those lines, which made me curious if cron is able to supress a log entry for selected processes?










share|improve this question















I was wondering if it is possible to having multiple cron jobs in crontab active, but only one of them starts each minute. The problem here is I wish to keep log of all others jobs informations with the exception of this only one.



Oct 25 14:50:01 dtest CRON[942]: (root) CMD (/usr/bin/python2.7 check.py > /dev/null 2>&1)


Currently I am getting flooded with all those lines, which made me curious if cron is able to supress a log entry for selected processes?







debian cron syslog






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









Rui F Ribeiro

38.8k1479128




38.8k1479128










asked Oct 25 at 19:03









RedS

183




183












  • I don't think cron is designed to be configured to not log event triggers for only one specific event. You can either log, or not. If you want to tail the log and eschew those entries, you can tail -f logfile | grep -v 'python2.7 check.py'.
    – DopeGhoti
    Oct 25 at 19:05






  • 1




    Just was curious if there is actually any possibility to hide specific entry. Thank You for clarification
    – RedS
    Oct 25 at 19:15










  • How are you being flooded? Email? Syslog? Something else?
    – roaima
    Oct 25 at 19:54


















  • I don't think cron is designed to be configured to not log event triggers for only one specific event. You can either log, or not. If you want to tail the log and eschew those entries, you can tail -f logfile | grep -v 'python2.7 check.py'.
    – DopeGhoti
    Oct 25 at 19:05






  • 1




    Just was curious if there is actually any possibility to hide specific entry. Thank You for clarification
    – RedS
    Oct 25 at 19:15










  • How are you being flooded? Email? Syslog? Something else?
    – roaima
    Oct 25 at 19:54
















I don't think cron is designed to be configured to not log event triggers for only one specific event. You can either log, or not. If you want to tail the log and eschew those entries, you can tail -f logfile | grep -v 'python2.7 check.py'.
– DopeGhoti
Oct 25 at 19:05




I don't think cron is designed to be configured to not log event triggers for only one specific event. You can either log, or not. If you want to tail the log and eschew those entries, you can tail -f logfile | grep -v 'python2.7 check.py'.
– DopeGhoti
Oct 25 at 19:05




1




1




Just was curious if there is actually any possibility to hide specific entry. Thank You for clarification
– RedS
Oct 25 at 19:15




Just was curious if there is actually any possibility to hide specific entry. Thank You for clarification
– RedS
Oct 25 at 19:15












How are you being flooded? Email? Syslog? Something else?
– roaima
Oct 25 at 19:54




How are you being flooded? Email? Syslog? Something else?
– roaima
Oct 25 at 19:54










1 Answer
1






active

oldest

votes


















1














On distros using cronie (e.g. CentOS, RHEL, openSUSE, Fedora, Gentoo, Arch etc), you can just use the special "-" entry in the first column of crontab.



Note that this doesn't help your situation, as you're on Debian, which uses Vixie cron



Example usage, on CentOS, below. See how the job to touch /tmp/foo2 did get run at 19:37 but did not record the run in /var/log/cron.



# crontab -l
* * * * * touch /tmp/foo1
-* * * * * touch /tmp/foo2
# ls -l /tmp/foo*
-rw-r--r--. 1 root root 0 Oct 25 19:37 /tmp/foo1
-rw-r--r--. 1 root root 0 Oct 25 19:37 /tmp/foo2
# grep foo /var/log/cron
Oct 25 19:37:01 instance-2 CROND[12639]: (root) CMD (touch /tmp/foo1)
#


I'm not sure where this is fully documented, but the code establishing this behaviour can be seen in cronie source code



/* check for '-' as a first character, this option will disable 
* writing a syslog message about command getting executed
*/
if (ch == '-') {
/* if we are editing system crontab or user uid is 0 (root)
* we are allowed to disable logging
*/
if (pw == NULL || pw->pw_uid == 0)
e->flags |= DONT_LOG;
else {
log_it("CRON", getpid(), "ERROR", "Only privileged user can disable logging", 0);
ecode = e_option;
goto eof;
}
ch = get_char(file);
if (ch == EOF) {
free(e);
return NULL;
}
}


Which is then referenced elsewhere in the cronie source code



if ((e->flags & DONT_LOG) == 0) {
char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
log_it(usernm, getpid(), "CMD", x, 0);
free(x);
}





share|improve this answer



















  • 1




    The source code you referred is of "cronie", not "cron". The latter produces an error message: "bad minute".
    – nst0022
    Oct 26 at 0:49






  • 1




    @nst0022 - Yes, on reflection, Debian uses Vixie cron, which lacks this functionality. Note added to answer. Have left it present in case helps any non-Debian users when faced with this challenge.
    – steve
    Oct 26 at 9:02











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%2f477814%2fpossibility-to-disable-or-hide-cron-notification-about-starting-one-specific-pro%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









1














On distros using cronie (e.g. CentOS, RHEL, openSUSE, Fedora, Gentoo, Arch etc), you can just use the special "-" entry in the first column of crontab.



Note that this doesn't help your situation, as you're on Debian, which uses Vixie cron



Example usage, on CentOS, below. See how the job to touch /tmp/foo2 did get run at 19:37 but did not record the run in /var/log/cron.



# crontab -l
* * * * * touch /tmp/foo1
-* * * * * touch /tmp/foo2
# ls -l /tmp/foo*
-rw-r--r--. 1 root root 0 Oct 25 19:37 /tmp/foo1
-rw-r--r--. 1 root root 0 Oct 25 19:37 /tmp/foo2
# grep foo /var/log/cron
Oct 25 19:37:01 instance-2 CROND[12639]: (root) CMD (touch /tmp/foo1)
#


I'm not sure where this is fully documented, but the code establishing this behaviour can be seen in cronie source code



/* check for '-' as a first character, this option will disable 
* writing a syslog message about command getting executed
*/
if (ch == '-') {
/* if we are editing system crontab or user uid is 0 (root)
* we are allowed to disable logging
*/
if (pw == NULL || pw->pw_uid == 0)
e->flags |= DONT_LOG;
else {
log_it("CRON", getpid(), "ERROR", "Only privileged user can disable logging", 0);
ecode = e_option;
goto eof;
}
ch = get_char(file);
if (ch == EOF) {
free(e);
return NULL;
}
}


Which is then referenced elsewhere in the cronie source code



if ((e->flags & DONT_LOG) == 0) {
char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
log_it(usernm, getpid(), "CMD", x, 0);
free(x);
}





share|improve this answer



















  • 1




    The source code you referred is of "cronie", not "cron". The latter produces an error message: "bad minute".
    – nst0022
    Oct 26 at 0:49






  • 1




    @nst0022 - Yes, on reflection, Debian uses Vixie cron, which lacks this functionality. Note added to answer. Have left it present in case helps any non-Debian users when faced with this challenge.
    – steve
    Oct 26 at 9:02
















1














On distros using cronie (e.g. CentOS, RHEL, openSUSE, Fedora, Gentoo, Arch etc), you can just use the special "-" entry in the first column of crontab.



Note that this doesn't help your situation, as you're on Debian, which uses Vixie cron



Example usage, on CentOS, below. See how the job to touch /tmp/foo2 did get run at 19:37 but did not record the run in /var/log/cron.



# crontab -l
* * * * * touch /tmp/foo1
-* * * * * touch /tmp/foo2
# ls -l /tmp/foo*
-rw-r--r--. 1 root root 0 Oct 25 19:37 /tmp/foo1
-rw-r--r--. 1 root root 0 Oct 25 19:37 /tmp/foo2
# grep foo /var/log/cron
Oct 25 19:37:01 instance-2 CROND[12639]: (root) CMD (touch /tmp/foo1)
#


I'm not sure where this is fully documented, but the code establishing this behaviour can be seen in cronie source code



/* check for '-' as a first character, this option will disable 
* writing a syslog message about command getting executed
*/
if (ch == '-') {
/* if we are editing system crontab or user uid is 0 (root)
* we are allowed to disable logging
*/
if (pw == NULL || pw->pw_uid == 0)
e->flags |= DONT_LOG;
else {
log_it("CRON", getpid(), "ERROR", "Only privileged user can disable logging", 0);
ecode = e_option;
goto eof;
}
ch = get_char(file);
if (ch == EOF) {
free(e);
return NULL;
}
}


Which is then referenced elsewhere in the cronie source code



if ((e->flags & DONT_LOG) == 0) {
char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
log_it(usernm, getpid(), "CMD", x, 0);
free(x);
}





share|improve this answer



















  • 1




    The source code you referred is of "cronie", not "cron". The latter produces an error message: "bad minute".
    – nst0022
    Oct 26 at 0:49






  • 1




    @nst0022 - Yes, on reflection, Debian uses Vixie cron, which lacks this functionality. Note added to answer. Have left it present in case helps any non-Debian users when faced with this challenge.
    – steve
    Oct 26 at 9:02














1












1








1






On distros using cronie (e.g. CentOS, RHEL, openSUSE, Fedora, Gentoo, Arch etc), you can just use the special "-" entry in the first column of crontab.



Note that this doesn't help your situation, as you're on Debian, which uses Vixie cron



Example usage, on CentOS, below. See how the job to touch /tmp/foo2 did get run at 19:37 but did not record the run in /var/log/cron.



# crontab -l
* * * * * touch /tmp/foo1
-* * * * * touch /tmp/foo2
# ls -l /tmp/foo*
-rw-r--r--. 1 root root 0 Oct 25 19:37 /tmp/foo1
-rw-r--r--. 1 root root 0 Oct 25 19:37 /tmp/foo2
# grep foo /var/log/cron
Oct 25 19:37:01 instance-2 CROND[12639]: (root) CMD (touch /tmp/foo1)
#


I'm not sure where this is fully documented, but the code establishing this behaviour can be seen in cronie source code



/* check for '-' as a first character, this option will disable 
* writing a syslog message about command getting executed
*/
if (ch == '-') {
/* if we are editing system crontab or user uid is 0 (root)
* we are allowed to disable logging
*/
if (pw == NULL || pw->pw_uid == 0)
e->flags |= DONT_LOG;
else {
log_it("CRON", getpid(), "ERROR", "Only privileged user can disable logging", 0);
ecode = e_option;
goto eof;
}
ch = get_char(file);
if (ch == EOF) {
free(e);
return NULL;
}
}


Which is then referenced elsewhere in the cronie source code



if ((e->flags & DONT_LOG) == 0) {
char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
log_it(usernm, getpid(), "CMD", x, 0);
free(x);
}





share|improve this answer














On distros using cronie (e.g. CentOS, RHEL, openSUSE, Fedora, Gentoo, Arch etc), you can just use the special "-" entry in the first column of crontab.



Note that this doesn't help your situation, as you're on Debian, which uses Vixie cron



Example usage, on CentOS, below. See how the job to touch /tmp/foo2 did get run at 19:37 but did not record the run in /var/log/cron.



# crontab -l
* * * * * touch /tmp/foo1
-* * * * * touch /tmp/foo2
# ls -l /tmp/foo*
-rw-r--r--. 1 root root 0 Oct 25 19:37 /tmp/foo1
-rw-r--r--. 1 root root 0 Oct 25 19:37 /tmp/foo2
# grep foo /var/log/cron
Oct 25 19:37:01 instance-2 CROND[12639]: (root) CMD (touch /tmp/foo1)
#


I'm not sure where this is fully documented, but the code establishing this behaviour can be seen in cronie source code



/* check for '-' as a first character, this option will disable 
* writing a syslog message about command getting executed
*/
if (ch == '-') {
/* if we are editing system crontab or user uid is 0 (root)
* we are allowed to disable logging
*/
if (pw == NULL || pw->pw_uid == 0)
e->flags |= DONT_LOG;
else {
log_it("CRON", getpid(), "ERROR", "Only privileged user can disable logging", 0);
ecode = e_option;
goto eof;
}
ch = get_char(file);
if (ch == EOF) {
free(e);
return NULL;
}
}


Which is then referenced elsewhere in the cronie source code



if ((e->flags & DONT_LOG) == 0) {
char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
log_it(usernm, getpid(), "CMD", x, 0);
free(x);
}






share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 26 at 9:01

























answered Oct 25 at 19:40









steve

13.9k22452




13.9k22452








  • 1




    The source code you referred is of "cronie", not "cron". The latter produces an error message: "bad minute".
    – nst0022
    Oct 26 at 0:49






  • 1




    @nst0022 - Yes, on reflection, Debian uses Vixie cron, which lacks this functionality. Note added to answer. Have left it present in case helps any non-Debian users when faced with this challenge.
    – steve
    Oct 26 at 9:02














  • 1




    The source code you referred is of "cronie", not "cron". The latter produces an error message: "bad minute".
    – nst0022
    Oct 26 at 0:49






  • 1




    @nst0022 - Yes, on reflection, Debian uses Vixie cron, which lacks this functionality. Note added to answer. Have left it present in case helps any non-Debian users when faced with this challenge.
    – steve
    Oct 26 at 9:02








1




1




The source code you referred is of "cronie", not "cron". The latter produces an error message: "bad minute".
– nst0022
Oct 26 at 0:49




The source code you referred is of "cronie", not "cron". The latter produces an error message: "bad minute".
– nst0022
Oct 26 at 0:49




1




1




@nst0022 - Yes, on reflection, Debian uses Vixie cron, which lacks this functionality. Note added to answer. Have left it present in case helps any non-Debian users when faced with this challenge.
– steve
Oct 26 at 9:02




@nst0022 - Yes, on reflection, Debian uses Vixie cron, which lacks this functionality. Note added to answer. Have left it present in case helps any non-Debian users when faced with this challenge.
– steve
Oct 26 at 9:02


















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f477814%2fpossibility-to-disable-or-hide-cron-notification-about-starting-one-specific-pro%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

サソリ

広島県道265号伴広島線

Setup Asymptote in Texstudio