Script in /etc/cron.hourly/ never running











up vote
3
down vote

favorite












I have a script in /etc/cron.hourly :



-rwxr-xr-x 1 root root 85 Dec  6 19:05 /etc/cron.hourly/nvidia_to_exclusive


containing (with an empty line at the end):



#!/bin/bash 

/usr/bin/nvidia-smi -c 1 > /home/user/nvidia-smi_set_exclusive.log


The script isn't executed by cron at all, even if using run-parts /etc/cron.hourly successfully execute it.



What could be missing ?










share|improve this question







New contributor




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
















  • 2




    Does anything show in /var/log/cron? eg mine says Dec 11 16:01:01 mercury7 CROND[30644]: (root) CMD (run-parts /etc/cron.hourly) Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30644]: starting 0anacron Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30667]: finished 0anacron. Errors may show, here.
    – Stephen Harris
    2 days ago










  • No, except when I manually call run-parts /etc/cron.hourly, then it say that it started/fnished Anacron0, then the same for my script. It's seems that run-parts /etc/cron.hourly isn't called.
    – Adrian B.
    2 days ago










  • Is it set executable? :)
    – tink
    2 days ago






  • 2




    What be the contents of /etc/crontab?
    – RudiC
    2 days ago










  • @tink yes, I don't think run-parts would works without that (and confirmed by ls anyway) :).
    – Adrian B.
    2 days ago















up vote
3
down vote

favorite












I have a script in /etc/cron.hourly :



-rwxr-xr-x 1 root root 85 Dec  6 19:05 /etc/cron.hourly/nvidia_to_exclusive


containing (with an empty line at the end):



#!/bin/bash 

/usr/bin/nvidia-smi -c 1 > /home/user/nvidia-smi_set_exclusive.log


The script isn't executed by cron at all, even if using run-parts /etc/cron.hourly successfully execute it.



What could be missing ?










share|improve this question







New contributor




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
















  • 2




    Does anything show in /var/log/cron? eg mine says Dec 11 16:01:01 mercury7 CROND[30644]: (root) CMD (run-parts /etc/cron.hourly) Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30644]: starting 0anacron Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30667]: finished 0anacron. Errors may show, here.
    – Stephen Harris
    2 days ago










  • No, except when I manually call run-parts /etc/cron.hourly, then it say that it started/fnished Anacron0, then the same for my script. It's seems that run-parts /etc/cron.hourly isn't called.
    – Adrian B.
    2 days ago










  • Is it set executable? :)
    – tink
    2 days ago






  • 2




    What be the contents of /etc/crontab?
    – RudiC
    2 days ago










  • @tink yes, I don't think run-parts would works without that (and confirmed by ls anyway) :).
    – Adrian B.
    2 days ago













up vote
3
down vote

favorite









up vote
3
down vote

favorite











I have a script in /etc/cron.hourly :



-rwxr-xr-x 1 root root 85 Dec  6 19:05 /etc/cron.hourly/nvidia_to_exclusive


containing (with an empty line at the end):



#!/bin/bash 

/usr/bin/nvidia-smi -c 1 > /home/user/nvidia-smi_set_exclusive.log


The script isn't executed by cron at all, even if using run-parts /etc/cron.hourly successfully execute it.



What could be missing ?










share|improve this question







New contributor




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











I have a script in /etc/cron.hourly :



-rwxr-xr-x 1 root root 85 Dec  6 19:05 /etc/cron.hourly/nvidia_to_exclusive


containing (with an empty line at the end):



#!/bin/bash 

/usr/bin/nvidia-smi -c 1 > /home/user/nvidia-smi_set_exclusive.log


The script isn't executed by cron at all, even if using run-parts /etc/cron.hourly successfully execute it.



What could be missing ?







centos cron






share|improve this question







New contributor




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











share|improve this question







New contributor




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









share|improve this question




share|improve this question






New contributor




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









asked 2 days ago









Adrian B.

564




564




New contributor




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





New contributor





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






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








  • 2




    Does anything show in /var/log/cron? eg mine says Dec 11 16:01:01 mercury7 CROND[30644]: (root) CMD (run-parts /etc/cron.hourly) Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30644]: starting 0anacron Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30667]: finished 0anacron. Errors may show, here.
    – Stephen Harris
    2 days ago










  • No, except when I manually call run-parts /etc/cron.hourly, then it say that it started/fnished Anacron0, then the same for my script. It's seems that run-parts /etc/cron.hourly isn't called.
    – Adrian B.
    2 days ago










  • Is it set executable? :)
    – tink
    2 days ago






  • 2




    What be the contents of /etc/crontab?
    – RudiC
    2 days ago










  • @tink yes, I don't think run-parts would works without that (and confirmed by ls anyway) :).
    – Adrian B.
    2 days ago














  • 2




    Does anything show in /var/log/cron? eg mine says Dec 11 16:01:01 mercury7 CROND[30644]: (root) CMD (run-parts /etc/cron.hourly) Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30644]: starting 0anacron Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30667]: finished 0anacron. Errors may show, here.
    – Stephen Harris
    2 days ago










  • No, except when I manually call run-parts /etc/cron.hourly, then it say that it started/fnished Anacron0, then the same for my script. It's seems that run-parts /etc/cron.hourly isn't called.
    – Adrian B.
    2 days ago










  • Is it set executable? :)
    – tink
    2 days ago






  • 2




    What be the contents of /etc/crontab?
    – RudiC
    2 days ago










  • @tink yes, I don't think run-parts would works without that (and confirmed by ls anyway) :).
    – Adrian B.
    2 days ago








2




2




Does anything show in /var/log/cron? eg mine says Dec 11 16:01:01 mercury7 CROND[30644]: (root) CMD (run-parts /etc/cron.hourly) Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30644]: starting 0anacron Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30667]: finished 0anacron. Errors may show, here.
– Stephen Harris
2 days ago




Does anything show in /var/log/cron? eg mine says Dec 11 16:01:01 mercury7 CROND[30644]: (root) CMD (run-parts /etc/cron.hourly) Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30644]: starting 0anacron Dec 11 16:01:01 mercury7 run-parts(/etc/cron.hourly)[30667]: finished 0anacron. Errors may show, here.
– Stephen Harris
2 days ago












No, except when I manually call run-parts /etc/cron.hourly, then it say that it started/fnished Anacron0, then the same for my script. It's seems that run-parts /etc/cron.hourly isn't called.
– Adrian B.
2 days ago




No, except when I manually call run-parts /etc/cron.hourly, then it say that it started/fnished Anacron0, then the same for my script. It's seems that run-parts /etc/cron.hourly isn't called.
– Adrian B.
2 days ago












Is it set executable? :)
– tink
2 days ago




Is it set executable? :)
– tink
2 days ago




2




2




What be the contents of /etc/crontab?
– RudiC
2 days ago




What be the contents of /etc/crontab?
– RudiC
2 days ago












@tink yes, I don't think run-parts would works without that (and confirmed by ls anyway) :).
– Adrian B.
2 days ago




@tink yes, I don't think run-parts would works without that (and confirmed by ls anyway) :).
– Adrian B.
2 days ago










1 Answer
1






active

oldest

votes

















up vote
4
down vote













The problem was that the cron service was inactive.



While I'm here, I'll summarize all the steps I've found to make a script in /etc/cron.hourly/ works :




  • Check that the name of your script is only using valid characters for run-parts, i.e. [a-zA-Z0-9_-].

    So don't use extension like .sh.

  • Check that your script is executable.

    If not : chmod +x /etc/cron.hourly/yourScript

  • Check that your script contains the shebang at the top (#!/bin/bash for example).

  • Check that your script runs with run-parts :
    run-parts --test /etc/cron.hourly → your script should be printed.
    run-parts /etc/cron.hourly→ your script should be executed.

    You can check at the end of /var/log/cron if your script successfully finished.

  • Check that cron is running with service crond status.

    If not : service crond stop then service crond start

  • Check if your /var/log/cron contains the error BAD FILE MODE (/etc/cron.d/0hourly).

    If it's the case, you probably need to execute chmod 0644 /etc/cron.d/0hourly (cron does not like this file to be executable).

  • Check - at least by default on CentOS 7 - that /etc/cron.d/0hourly exists and contains the line
    01 * * * * root run-parts /etc/cron.hourly






share|improve this answer










New contributor




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


















  • Excellent self-answer, glad you got it working. You should accept your answer as well, just to close the cycle
    – ivanivan
    2 days ago










  • Thanks. I'll accept my answer in two days (I can't before) :).
    – Adrian B.
    2 days ago











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',
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
});


}
});






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










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487448%2fscript-in-etc-cron-hourly-never-running%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








up vote
4
down vote













The problem was that the cron service was inactive.



While I'm here, I'll summarize all the steps I've found to make a script in /etc/cron.hourly/ works :




  • Check that the name of your script is only using valid characters for run-parts, i.e. [a-zA-Z0-9_-].

    So don't use extension like .sh.

  • Check that your script is executable.

    If not : chmod +x /etc/cron.hourly/yourScript

  • Check that your script contains the shebang at the top (#!/bin/bash for example).

  • Check that your script runs with run-parts :
    run-parts --test /etc/cron.hourly → your script should be printed.
    run-parts /etc/cron.hourly→ your script should be executed.

    You can check at the end of /var/log/cron if your script successfully finished.

  • Check that cron is running with service crond status.

    If not : service crond stop then service crond start

  • Check if your /var/log/cron contains the error BAD FILE MODE (/etc/cron.d/0hourly).

    If it's the case, you probably need to execute chmod 0644 /etc/cron.d/0hourly (cron does not like this file to be executable).

  • Check - at least by default on CentOS 7 - that /etc/cron.d/0hourly exists and contains the line
    01 * * * * root run-parts /etc/cron.hourly






share|improve this answer










New contributor




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


















  • Excellent self-answer, glad you got it working. You should accept your answer as well, just to close the cycle
    – ivanivan
    2 days ago










  • Thanks. I'll accept my answer in two days (I can't before) :).
    – Adrian B.
    2 days ago















up vote
4
down vote













The problem was that the cron service was inactive.



While I'm here, I'll summarize all the steps I've found to make a script in /etc/cron.hourly/ works :




  • Check that the name of your script is only using valid characters for run-parts, i.e. [a-zA-Z0-9_-].

    So don't use extension like .sh.

  • Check that your script is executable.

    If not : chmod +x /etc/cron.hourly/yourScript

  • Check that your script contains the shebang at the top (#!/bin/bash for example).

  • Check that your script runs with run-parts :
    run-parts --test /etc/cron.hourly → your script should be printed.
    run-parts /etc/cron.hourly→ your script should be executed.

    You can check at the end of /var/log/cron if your script successfully finished.

  • Check that cron is running with service crond status.

    If not : service crond stop then service crond start

  • Check if your /var/log/cron contains the error BAD FILE MODE (/etc/cron.d/0hourly).

    If it's the case, you probably need to execute chmod 0644 /etc/cron.d/0hourly (cron does not like this file to be executable).

  • Check - at least by default on CentOS 7 - that /etc/cron.d/0hourly exists and contains the line
    01 * * * * root run-parts /etc/cron.hourly






share|improve this answer










New contributor




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


















  • Excellent self-answer, glad you got it working. You should accept your answer as well, just to close the cycle
    – ivanivan
    2 days ago










  • Thanks. I'll accept my answer in two days (I can't before) :).
    – Adrian B.
    2 days ago













up vote
4
down vote










up vote
4
down vote









The problem was that the cron service was inactive.



While I'm here, I'll summarize all the steps I've found to make a script in /etc/cron.hourly/ works :




  • Check that the name of your script is only using valid characters for run-parts, i.e. [a-zA-Z0-9_-].

    So don't use extension like .sh.

  • Check that your script is executable.

    If not : chmod +x /etc/cron.hourly/yourScript

  • Check that your script contains the shebang at the top (#!/bin/bash for example).

  • Check that your script runs with run-parts :
    run-parts --test /etc/cron.hourly → your script should be printed.
    run-parts /etc/cron.hourly→ your script should be executed.

    You can check at the end of /var/log/cron if your script successfully finished.

  • Check that cron is running with service crond status.

    If not : service crond stop then service crond start

  • Check if your /var/log/cron contains the error BAD FILE MODE (/etc/cron.d/0hourly).

    If it's the case, you probably need to execute chmod 0644 /etc/cron.d/0hourly (cron does not like this file to be executable).

  • Check - at least by default on CentOS 7 - that /etc/cron.d/0hourly exists and contains the line
    01 * * * * root run-parts /etc/cron.hourly






share|improve this answer










New contributor




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









The problem was that the cron service was inactive.



While I'm here, I'll summarize all the steps I've found to make a script in /etc/cron.hourly/ works :




  • Check that the name of your script is only using valid characters for run-parts, i.e. [a-zA-Z0-9_-].

    So don't use extension like .sh.

  • Check that your script is executable.

    If not : chmod +x /etc/cron.hourly/yourScript

  • Check that your script contains the shebang at the top (#!/bin/bash for example).

  • Check that your script runs with run-parts :
    run-parts --test /etc/cron.hourly → your script should be printed.
    run-parts /etc/cron.hourly→ your script should be executed.

    You can check at the end of /var/log/cron if your script successfully finished.

  • Check that cron is running with service crond status.

    If not : service crond stop then service crond start

  • Check if your /var/log/cron contains the error BAD FILE MODE (/etc/cron.d/0hourly).

    If it's the case, you probably need to execute chmod 0644 /etc/cron.d/0hourly (cron does not like this file to be executable).

  • Check - at least by default on CentOS 7 - that /etc/cron.d/0hourly exists and contains the line
    01 * * * * root run-parts /etc/cron.hourly







share|improve this answer










New contributor




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









share|improve this answer



share|improve this answer








edited yesterday





















New contributor




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









answered 2 days ago









Adrian B.

564




564




New contributor




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





New contributor





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






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












  • Excellent self-answer, glad you got it working. You should accept your answer as well, just to close the cycle
    – ivanivan
    2 days ago










  • Thanks. I'll accept my answer in two days (I can't before) :).
    – Adrian B.
    2 days ago


















  • Excellent self-answer, glad you got it working. You should accept your answer as well, just to close the cycle
    – ivanivan
    2 days ago










  • Thanks. I'll accept my answer in two days (I can't before) :).
    – Adrian B.
    2 days ago
















Excellent self-answer, glad you got it working. You should accept your answer as well, just to close the cycle
– ivanivan
2 days ago




Excellent self-answer, glad you got it working. You should accept your answer as well, just to close the cycle
– ivanivan
2 days ago












Thanks. I'll accept my answer in two days (I can't before) :).
– Adrian B.
2 days ago




Thanks. I'll accept my answer in two days (I can't before) :).
– Adrian B.
2 days ago










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










draft saved

draft discarded


















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













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












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
















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


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

But avoid



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

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


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





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%2f487448%2fscript-in-etc-cron-hourly-never-running%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