Cron task won't run, although all is correctly set up Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionTracking huge buffer usage under LinuxSend cron mails to root bundled every hourEntries in /etc/crontab not getting called in Centos 6.xcrontab not launching one scriptcrontab: “Temporary crontab no longer owned by you.”Why would /etc/crontab set HOME=/ in environment?Is it possible to write to the crontab from a multipurpose script?Is there a common way of auto-updates with cron?Why is crond failing to run a non-root crontab on alpine linux?Cron log shows shell script has run but it really hasn't
Am I ethically obligated to go into work on an off day if the reason is sudden?
What's the point in a preamp?
Stars Make Stars
Can't figure this one out.. What is the missing box?
Classification of bundles, Postnikov towers, obstruction theory, local coefficients
Windows 10: How to Lock (not sleep) laptop on lid close?
Stop battery usage [Ubuntu 18]
Writing Thesis: Copying from published papers
Was credit for the black hole image misattributed?
How to add zeros to reach same number of decimal places in tables?
How does modal jazz use chord progressions?
Can I throw a sword that doesn't have the Thrown property at someone?
Strange behaviour of Check
What's the difference between (size_t)-1 and ~0?
Keep going mode for require-package
How many spell slots should a Fighter 11/Ranger 9 have?
Complexity of many constant time steps with occasional logarithmic steps
Estimate capacitor parameters
What is the largest species of polychaete?
Estimated State payment too big --> money back; + 2018 Tax Reform
Need a suitable toxic chemical for a murder plot in my novel
Aligning matrix of nodes with grid
When is phishing education going too far?
Did the new image of black hole confirm the general theory of relativity?
Cron task won't run, although all is correctly set up
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionTracking huge buffer usage under LinuxSend cron mails to root bundled every hourEntries in /etc/crontab not getting called in Centos 6.xcrontab not launching one scriptcrontab: “Temporary crontab no longer owned by you.”Why would /etc/crontab set HOME=/ in environment?Is it possible to write to the crontab from a multipurpose script?Is there a common way of auto-updates with cron?Why is crond failing to run a non-root crontab on alpine linux?Cron log shows shell script has run but it really hasn't
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
This cron tqsk doesn't work:
[main_usr@localhost ~]$ sudo crontab -l -u root
0 * * * * /home/main_usr/cron_test1.sh > /home/main_usr/cron_test1_out.sh.out 2>&1
[main_usr@localhost ~]$
And
$ ls -al cron_test1.sh
-rwxr-xr-x 1 main_usr main_usr 293 Apr 8 05:12 cron_test1.sh
As you can see, there's a new line in the cron tasks. And the file exists and is executable. The task was created a day ago. It should've run once in an hour. Nonetheless, 'cron_test1_out.sh.out' hasn't been created.
Why?
linux cron
add a comment |
This cron tqsk doesn't work:
[main_usr@localhost ~]$ sudo crontab -l -u root
0 * * * * /home/main_usr/cron_test1.sh > /home/main_usr/cron_test1_out.sh.out 2>&1
[main_usr@localhost ~]$
And
$ ls -al cron_test1.sh
-rwxr-xr-x 1 main_usr main_usr 293 Apr 8 05:12 cron_test1.sh
As you can see, there's a new line in the cron tasks. And the file exists and is executable. The task was created a day ago. It should've run once in an hour. Nonetheless, 'cron_test1_out.sh.out' hasn't been created.
Why?
linux cron
1
Has root received any email from the cron daemon containing errors?
– Kusalananda♦
Apr 10 at 20:08
2
What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is thecron
daemon running?
– hymie
Apr 10 at 20:08
Do other cron jobs work? If not, is the cron service running?
– K7AAY
Apr 10 at 20:35
add a comment |
This cron tqsk doesn't work:
[main_usr@localhost ~]$ sudo crontab -l -u root
0 * * * * /home/main_usr/cron_test1.sh > /home/main_usr/cron_test1_out.sh.out 2>&1
[main_usr@localhost ~]$
And
$ ls -al cron_test1.sh
-rwxr-xr-x 1 main_usr main_usr 293 Apr 8 05:12 cron_test1.sh
As you can see, there's a new line in the cron tasks. And the file exists and is executable. The task was created a day ago. It should've run once in an hour. Nonetheless, 'cron_test1_out.sh.out' hasn't been created.
Why?
linux cron
This cron tqsk doesn't work:
[main_usr@localhost ~]$ sudo crontab -l -u root
0 * * * * /home/main_usr/cron_test1.sh > /home/main_usr/cron_test1_out.sh.out 2>&1
[main_usr@localhost ~]$
And
$ ls -al cron_test1.sh
-rwxr-xr-x 1 main_usr main_usr 293 Apr 8 05:12 cron_test1.sh
As you can see, there's a new line in the cron tasks. And the file exists and is executable. The task was created a day ago. It should've run once in an hour. Nonetheless, 'cron_test1_out.sh.out' hasn't been created.
Why?
linux cron
linux cron
asked Apr 10 at 20:05
jijinojijino
11
11
1
Has root received any email from the cron daemon containing errors?
– Kusalananda♦
Apr 10 at 20:08
2
What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is thecron
daemon running?
– hymie
Apr 10 at 20:08
Do other cron jobs work? If not, is the cron service running?
– K7AAY
Apr 10 at 20:35
add a comment |
1
Has root received any email from the cron daemon containing errors?
– Kusalananda♦
Apr 10 at 20:08
2
What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is thecron
daemon running?
– hymie
Apr 10 at 20:08
Do other cron jobs work? If not, is the cron service running?
– K7AAY
Apr 10 at 20:35
1
1
Has root received any email from the cron daemon containing errors?
– Kusalananda♦
Apr 10 at 20:08
Has root received any email from the cron daemon containing errors?
– Kusalananda♦
Apr 10 at 20:08
2
2
What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is the
cron
daemon running?– hymie
Apr 10 at 20:08
What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is the
cron
daemon running?– hymie
Apr 10 at 20:08
Do other cron jobs work? If not, is the cron service running?
– K7AAY
Apr 10 at 20:35
Do other cron jobs work? If not, is the cron service running?
– K7AAY
Apr 10 at 20:35
add a comment |
2 Answers
2
active
oldest
votes
Cron tasks are run with /bin/sh and a blank environment, so sometimes you may need to source your bash profile or some other environment file, or optionally, include the environment variables in the cron file. PATH is usually the biggest offender. By default, path is set to /usr/bin:/bin, so if your script refers to any executables that are not in these two directories without the full path, your cron will fail. You can set any of the environment variable in the crontab with a simple KEY=VALUE, such as
PATH=/usr/bin:/bin:/usr/local/bin
New contributor
add a comment |
I had the same issue some time ago.
Adding /bin/bash fixed it for me.
Example:
0 * * * * /bin/bash /path_to_your_script/script.sh > /output_directory
Reason:
When running a shell script you have to define where the script should be executed, so probably you have to use /bin/sh, /bin/zsh or what ever to run the script within.
Cron itself does not know where to run the script.
Please also check /var/log/syslog and /var/mail/root to see the reason.
New contributor
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%2f511751%2fcron-task-wont-run-although-all-is-correctly-set-up%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
Cron tasks are run with /bin/sh and a blank environment, so sometimes you may need to source your bash profile or some other environment file, or optionally, include the environment variables in the cron file. PATH is usually the biggest offender. By default, path is set to /usr/bin:/bin, so if your script refers to any executables that are not in these two directories without the full path, your cron will fail. You can set any of the environment variable in the crontab with a simple KEY=VALUE, such as
PATH=/usr/bin:/bin:/usr/local/bin
New contributor
add a comment |
Cron tasks are run with /bin/sh and a blank environment, so sometimes you may need to source your bash profile or some other environment file, or optionally, include the environment variables in the cron file. PATH is usually the biggest offender. By default, path is set to /usr/bin:/bin, so if your script refers to any executables that are not in these two directories without the full path, your cron will fail. You can set any of the environment variable in the crontab with a simple KEY=VALUE, such as
PATH=/usr/bin:/bin:/usr/local/bin
New contributor
add a comment |
Cron tasks are run with /bin/sh and a blank environment, so sometimes you may need to source your bash profile or some other environment file, or optionally, include the environment variables in the cron file. PATH is usually the biggest offender. By default, path is set to /usr/bin:/bin, so if your script refers to any executables that are not in these two directories without the full path, your cron will fail. You can set any of the environment variable in the crontab with a simple KEY=VALUE, such as
PATH=/usr/bin:/bin:/usr/local/bin
New contributor
Cron tasks are run with /bin/sh and a blank environment, so sometimes you may need to source your bash profile or some other environment file, or optionally, include the environment variables in the cron file. PATH is usually the biggest offender. By default, path is set to /usr/bin:/bin, so if your script refers to any executables that are not in these two directories without the full path, your cron will fail. You can set any of the environment variable in the crontab with a simple KEY=VALUE, such as
PATH=/usr/bin:/bin:/usr/local/bin
New contributor
New contributor
answered Apr 10 at 21:19
Mike BreedMike Breed
1
1
New contributor
New contributor
add a comment |
add a comment |
I had the same issue some time ago.
Adding /bin/bash fixed it for me.
Example:
0 * * * * /bin/bash /path_to_your_script/script.sh > /output_directory
Reason:
When running a shell script you have to define where the script should be executed, so probably you have to use /bin/sh, /bin/zsh or what ever to run the script within.
Cron itself does not know where to run the script.
Please also check /var/log/syslog and /var/mail/root to see the reason.
New contributor
add a comment |
I had the same issue some time ago.
Adding /bin/bash fixed it for me.
Example:
0 * * * * /bin/bash /path_to_your_script/script.sh > /output_directory
Reason:
When running a shell script you have to define where the script should be executed, so probably you have to use /bin/sh, /bin/zsh or what ever to run the script within.
Cron itself does not know where to run the script.
Please also check /var/log/syslog and /var/mail/root to see the reason.
New contributor
add a comment |
I had the same issue some time ago.
Adding /bin/bash fixed it for me.
Example:
0 * * * * /bin/bash /path_to_your_script/script.sh > /output_directory
Reason:
When running a shell script you have to define where the script should be executed, so probably you have to use /bin/sh, /bin/zsh or what ever to run the script within.
Cron itself does not know where to run the script.
Please also check /var/log/syslog and /var/mail/root to see the reason.
New contributor
I had the same issue some time ago.
Adding /bin/bash fixed it for me.
Example:
0 * * * * /bin/bash /path_to_your_script/script.sh > /output_directory
Reason:
When running a shell script you have to define where the script should be executed, so probably you have to use /bin/sh, /bin/zsh or what ever to run the script within.
Cron itself does not know where to run the script.
Please also check /var/log/syslog and /var/mail/root to see the reason.
New contributor
edited Apr 10 at 21:22
New contributor
answered Apr 10 at 21:03
SchnarchnaseSchnarchnase
11
11
New contributor
New contributor
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%2f511751%2fcron-task-wont-run-although-all-is-correctly-set-up%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
1
Has root received any email from the cron daemon containing errors?
– Kusalananda♦
Apr 10 at 20:08
2
What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is the
cron
daemon running?– hymie
Apr 10 at 20:08
Do other cron jobs work? If not, is the cron service running?
– K7AAY
Apr 10 at 20:35