cron not executing python3
I am running Raspbian Stretch and have a python 3 script that executes correctly when I am in the relevant directory and input it in the command line as:
sudo python3 Example.py
The shebang #! line is in the script as follows:
#!/usr/bin/env python3
And made the script executable with:
sudo chmod +x Example.py
I've tried several variation of below within crontab -e to no avail
10 * * * * python3 /home/pi/Desktop/Example.py
raspbian-stretch python-3 cron
add a comment |
I am running Raspbian Stretch and have a python 3 script that executes correctly when I am in the relevant directory and input it in the command line as:
sudo python3 Example.py
The shebang #! line is in the script as follows:
#!/usr/bin/env python3
And made the script executable with:
sudo chmod +x Example.py
I've tried several variation of below within crontab -e to no avail
10 * * * * python3 /home/pi/Desktop/Example.py
raspbian-stretch python-3 cron
add a comment |
I am running Raspbian Stretch and have a python 3 script that executes correctly when I am in the relevant directory and input it in the command line as:
sudo python3 Example.py
The shebang #! line is in the script as follows:
#!/usr/bin/env python3
And made the script executable with:
sudo chmod +x Example.py
I've tried several variation of below within crontab -e to no avail
10 * * * * python3 /home/pi/Desktop/Example.py
raspbian-stretch python-3 cron
I am running Raspbian Stretch and have a python 3 script that executes correctly when I am in the relevant directory and input it in the command line as:
sudo python3 Example.py
The shebang #! line is in the script as follows:
#!/usr/bin/env python3
And made the script executable with:
sudo chmod +x Example.py
I've tried several variation of below within crontab -e to no avail
10 * * * * python3 /home/pi/Desktop/Example.py
raspbian-stretch python-3 cron
raspbian-stretch python-3 cron
asked 2 hours ago
Dan B RaelinDan B Raelin
257
257
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
As is typical with crontab issues. The environment is not the same as your user or even a sudo/root shell , and env python3 may not return anything (env simply searches through
Instead you should explicitly use the full path of python which can be found either as which python3 or which $(env python3) and use that full path in your cronttab (typically /usr/bin/python3 but it is also valid to use one installed elsewhere , e.g. a virtualenv directory)
Note shebangs are ignored when called script is called explicitly as argument to python
– crasic
2 hours ago
The script should alsocd <relevant directory>.
– Ingo
26 mins ago
add a comment |
Try the following in crontab:
sudo python3 /home/pi/Example.py
You need the full path to Example.py
You don't really need the shebang.
Or sudo crontab -e for the root crontab with:
python3 /home/pi/Example.py
New contributor
Steve Amor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The script should alsocd <relevant directory>.
– Ingo
24 mins ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("schematics", function () {
StackExchange.schematics.init();
});
}, "cicuitlab");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "447"
};
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%2fraspberrypi.stackexchange.com%2fquestions%2f94818%2fcron-not-executing-python3%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
As is typical with crontab issues. The environment is not the same as your user or even a sudo/root shell , and env python3 may not return anything (env simply searches through
Instead you should explicitly use the full path of python which can be found either as which python3 or which $(env python3) and use that full path in your cronttab (typically /usr/bin/python3 but it is also valid to use one installed elsewhere , e.g. a virtualenv directory)
Note shebangs are ignored when called script is called explicitly as argument to python
– crasic
2 hours ago
The script should alsocd <relevant directory>.
– Ingo
26 mins ago
add a comment |
As is typical with crontab issues. The environment is not the same as your user or even a sudo/root shell , and env python3 may not return anything (env simply searches through
Instead you should explicitly use the full path of python which can be found either as which python3 or which $(env python3) and use that full path in your cronttab (typically /usr/bin/python3 but it is also valid to use one installed elsewhere , e.g. a virtualenv directory)
Note shebangs are ignored when called script is called explicitly as argument to python
– crasic
2 hours ago
The script should alsocd <relevant directory>.
– Ingo
26 mins ago
add a comment |
As is typical with crontab issues. The environment is not the same as your user or even a sudo/root shell , and env python3 may not return anything (env simply searches through
Instead you should explicitly use the full path of python which can be found either as which python3 or which $(env python3) and use that full path in your cronttab (typically /usr/bin/python3 but it is also valid to use one installed elsewhere , e.g. a virtualenv directory)
As is typical with crontab issues. The environment is not the same as your user or even a sudo/root shell , and env python3 may not return anything (env simply searches through
Instead you should explicitly use the full path of python which can be found either as which python3 or which $(env python3) and use that full path in your cronttab (typically /usr/bin/python3 but it is also valid to use one installed elsewhere , e.g. a virtualenv directory)
answered 2 hours ago
crasiccrasic
2,256318
2,256318
Note shebangs are ignored when called script is called explicitly as argument to python
– crasic
2 hours ago
The script should alsocd <relevant directory>.
– Ingo
26 mins ago
add a comment |
Note shebangs are ignored when called script is called explicitly as argument to python
– crasic
2 hours ago
The script should alsocd <relevant directory>.
– Ingo
26 mins ago
Note shebangs are ignored when called script is called explicitly as argument to python
– crasic
2 hours ago
Note shebangs are ignored when called script is called explicitly as argument to python
– crasic
2 hours ago
The script should also
cd <relevant directory>.– Ingo
26 mins ago
The script should also
cd <relevant directory>.– Ingo
26 mins ago
add a comment |
Try the following in crontab:
sudo python3 /home/pi/Example.py
You need the full path to Example.py
You don't really need the shebang.
Or sudo crontab -e for the root crontab with:
python3 /home/pi/Example.py
New contributor
Steve Amor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The script should alsocd <relevant directory>.
– Ingo
24 mins ago
add a comment |
Try the following in crontab:
sudo python3 /home/pi/Example.py
You need the full path to Example.py
You don't really need the shebang.
Or sudo crontab -e for the root crontab with:
python3 /home/pi/Example.py
New contributor
Steve Amor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The script should alsocd <relevant directory>.
– Ingo
24 mins ago
add a comment |
Try the following in crontab:
sudo python3 /home/pi/Example.py
You need the full path to Example.py
You don't really need the shebang.
Or sudo crontab -e for the root crontab with:
python3 /home/pi/Example.py
New contributor
Steve Amor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Try the following in crontab:
sudo python3 /home/pi/Example.py
You need the full path to Example.py
You don't really need the shebang.
Or sudo crontab -e for the root crontab with:
python3 /home/pi/Example.py
New contributor
Steve Amor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Steve Amor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 56 mins ago
Steve AmorSteve Amor
111
111
New contributor
Steve Amor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Steve Amor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Steve Amor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The script should alsocd <relevant directory>.
– Ingo
24 mins ago
add a comment |
The script should alsocd <relevant directory>.
– Ingo
24 mins ago
The script should also
cd <relevant directory>.– Ingo
24 mins ago
The script should also
cd <relevant directory>.– Ingo
24 mins ago
add a comment |
Thanks for contributing an answer to Raspberry Pi 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%2fraspberrypi.stackexchange.com%2fquestions%2f94818%2fcron-not-executing-python3%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