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 ?
centos cron
New contributor
|
show 4 more comments
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 ?
centos cron
New contributor
2
Does anything show in/var/log/cron
? eg mine saysDec 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 callrun-parts /etc/cron.hourly
, then it say that it started/fnished Anacron0, then the same for my script. It's seems thatrun-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
|
show 4 more comments
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 ?
centos cron
New contributor
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
centos cron
New contributor
New contributor
New contributor
asked 2 days ago
Adrian B.
564
564
New contributor
New contributor
2
Does anything show in/var/log/cron
? eg mine saysDec 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 callrun-parts /etc/cron.hourly
, then it say that it started/fnished Anacron0, then the same for my script. It's seems thatrun-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
|
show 4 more comments
2
Does anything show in/var/log/cron
? eg mine saysDec 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 callrun-parts /etc/cron.hourly
, then it say that it started/fnished Anacron0, then the same for my script. It's seems thatrun-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
|
show 4 more comments
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
thenservice crond start
- Check if your
/var/log/cron
contains the errorBAD FILE MODE (/etc/cron.d/0hourly)
.
If it's the case, you probably need to executechmod 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 line01 * * * * root run-parts /etc/cron.hourly
New contributor
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
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',
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.
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%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
thenservice crond start
- Check if your
/var/log/cron
contains the errorBAD FILE MODE (/etc/cron.d/0hourly)
.
If it's the case, you probably need to executechmod 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 line01 * * * * root run-parts /etc/cron.hourly
New contributor
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
add a comment |
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
thenservice crond start
- Check if your
/var/log/cron
contains the errorBAD FILE MODE (/etc/cron.d/0hourly)
.
If it's the case, you probably need to executechmod 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 line01 * * * * root run-parts /etc/cron.hourly
New contributor
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
add a comment |
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
thenservice crond start
- Check if your
/var/log/cron
contains the errorBAD FILE MODE (/etc/cron.d/0hourly)
.
If it's the case, you probably need to executechmod 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 line01 * * * * root run-parts /etc/cron.hourly
New contributor
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
thenservice crond start
- Check if your
/var/log/cron
contains the errorBAD FILE MODE (/etc/cron.d/0hourly)
.
If it's the case, you probably need to executechmod 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 line01 * * * * root run-parts /etc/cron.hourly
New contributor
edited yesterday
New contributor
answered 2 days ago
Adrian B.
564
564
New contributor
New contributor
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
add a comment |
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
add a comment |
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.
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.
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%2f487448%2fscript-in-etc-cron-hourly-never-running%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
2
Does anything show in
/var/log/cron
? eg mine saysDec 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 thatrun-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