Python script not working on crontabcrontab does not work correctly python file okPython script won't write data when ran from cron(Python) Spyder not startingRunning a command at startup not working (due to network not being up when the code was run)Bash script doesn't work properly in crontab but does work manuallyCrontab doesnt run python scriptScript not running at startup using crontabCron not working, although the command works
Transiting through Switzerland by coach with lots of cash
Why has Donald Trump's popularity remained so stable over a rather long period of time?
What is the next number in the series: 21, 21, 23, 20, 5, 25, 31, 24,?
How to find an internship in OR/Optimization?
A sentient carnivorous species trying to preserve life. How could they find a new food source?
How to discipline overeager engineer
Accounting for intervals not present within the chord ratio?
What is the fastest way to move in Borderlands 3?
Difference between $HOME and ~
Can I color text by using an image, so that the color isn't flat?
Why can I ping 10.0.0.0/8 addresses from a 192.168.1.0/24 subnet?
Modern warfare theory in a medieval setting
Does journal access significantly influence choice in which journal to publish in?
How to write Hanief (my name) in Japanese?
Should I withdraw my paper because the Editor is behaving so badly with me?
How long could a human survive completely without the immune system?
Rat proofing compost bin but allowing worms in
What kind of mission objective would make a parabolic escape trajectory desirable?
How can I curtail abuse of the Illusion wizard's Illusory Reality feature?
I am confused with the word order when putting a sentence into passé composé with reflexive verbs
What ways are there to bypass spell resistance?
Does the Creighton Method of Natural Family Planning have a failure rate of 3.2% or less?
how do you value what your leisure time is worth?
Why is matter-antimatter asymmetry surprising, if asymmetry can be generated by a random walk in which particles go into black holes?
Python script not working on crontab
crontab does not work correctly python file okPython script won't write data when ran from cron(Python) Spyder not startingRunning a command at startup not working (due to network not being up when the code was run)Bash script doesn't work properly in crontab but does work manuallyCrontab doesnt run python scriptScript not running at startup using crontabCron not working, although the command works
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I have this python script. I'm trying to run it on a crontab, but it isn't working:
from datetime import datetime
x="Hello, it is now %s." % datetime.now().strftime('%d-%m-%Y %H:%M:%S')
import csv
try:
with open('output.csv', 'w+') as csvFile:
writer=csv.writer(csvFile)
writer.writerow(x)
finally:
csvFile.close()
The crontab is defined as:
attyan22@LAPTOP-SGBTV53C:~$ crontab -l
* * * * * python hello_time.py
attyan22@LAPTOP-SGBTV53C:~$ service crond start
crond: unrecognized service
I want to run automatically, but it does not working. This is just test .
python cron
add a comment
|
I have this python script. I'm trying to run it on a crontab, but it isn't working:
from datetime import datetime
x="Hello, it is now %s." % datetime.now().strftime('%d-%m-%Y %H:%M:%S')
import csv
try:
with open('output.csv', 'w+') as csvFile:
writer=csv.writer(csvFile)
writer.writerow(x)
finally:
csvFile.close()
The crontab is defined as:
attyan22@LAPTOP-SGBTV53C:~$ crontab -l
* * * * * python hello_time.py
attyan22@LAPTOP-SGBTV53C:~$ service crond start
crond: unrecognized service
I want to run automatically, but it does not working. This is just test .
python cron
1
1) Is cron active? 2) Does your script work in a terminal? 3) Does cron find python and the file hello_time.py?
– muclux
Apr 17 at 18:49
1 crond not 2yes
– Atsushi
Apr 17 at 20:18
add a comment
|
I have this python script. I'm trying to run it on a crontab, but it isn't working:
from datetime import datetime
x="Hello, it is now %s." % datetime.now().strftime('%d-%m-%Y %H:%M:%S')
import csv
try:
with open('output.csv', 'w+') as csvFile:
writer=csv.writer(csvFile)
writer.writerow(x)
finally:
csvFile.close()
The crontab is defined as:
attyan22@LAPTOP-SGBTV53C:~$ crontab -l
* * * * * python hello_time.py
attyan22@LAPTOP-SGBTV53C:~$ service crond start
crond: unrecognized service
I want to run automatically, but it does not working. This is just test .
python cron
I have this python script. I'm trying to run it on a crontab, but it isn't working:
from datetime import datetime
x="Hello, it is now %s." % datetime.now().strftime('%d-%m-%Y %H:%M:%S')
import csv
try:
with open('output.csv', 'w+') as csvFile:
writer=csv.writer(csvFile)
writer.writerow(x)
finally:
csvFile.close()
The crontab is defined as:
attyan22@LAPTOP-SGBTV53C:~$ crontab -l
* * * * * python hello_time.py
attyan22@LAPTOP-SGBTV53C:~$ service crond start
crond: unrecognized service
I want to run automatically, but it does not working. This is just test .
python cron
python cron
edited Apr 17 at 20:16
Atsushi
asked Apr 17 at 18:37
AtsushiAtsushi
135 bronze badges
135 bronze badges
1
1) Is cron active? 2) Does your script work in a terminal? 3) Does cron find python and the file hello_time.py?
– muclux
Apr 17 at 18:49
1 crond not 2yes
– Atsushi
Apr 17 at 20:18
add a comment
|
1
1) Is cron active? 2) Does your script work in a terminal? 3) Does cron find python and the file hello_time.py?
– muclux
Apr 17 at 18:49
1 crond not 2yes
– Atsushi
Apr 17 at 20:18
1
1
1) Is cron active? 2) Does your script work in a terminal? 3) Does cron find python and the file hello_time.py?
– muclux
Apr 17 at 18:49
1) Is cron active? 2) Does your script work in a terminal? 3) Does cron find python and the file hello_time.py?
– muclux
Apr 17 at 18:49
1 crond not 2yes
– Atsushi
Apr 17 at 20:18
1 crond not 2yes
– Atsushi
Apr 17 at 20:18
add a comment
|
1 Answer
1
active
oldest
votes
You need to give full path to hello_time.py
.
Try
* * * * * /usr/bin/python /path/to/hello_time.py
Replace /path/to
with actual path for hello_time.py
. This you can get by running pwd
from the directory it's located in.
like this * * * * * /usr/bin/python C:Usersa.sakataDesktoppython_lessonhello_time.py ? but still no
– Atsushi
Apr 17 at 20:19
C: ? It is a windows or Linux environment?
– JucaPirama
Apr 17 at 20:44
Are you using WSL?
– vidarlo
Apr 17 at 21:00
I use windows ubuntu
– Atsushi
Apr 17 at 21:04
1
Sorry. My mistake. You need to use forward slashes in the path, not backslashes. Anyway, my advice stands.
– vidarlo
Apr 17 at 22:08
|
show 4 more comments
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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/4.0/"u003ecc by-sa 4.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%2faskubuntu.com%2fquestions%2f1134730%2fpython-script-not-working-on-crontab%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
You need to give full path to hello_time.py
.
Try
* * * * * /usr/bin/python /path/to/hello_time.py
Replace /path/to
with actual path for hello_time.py
. This you can get by running pwd
from the directory it's located in.
like this * * * * * /usr/bin/python C:Usersa.sakataDesktoppython_lessonhello_time.py ? but still no
– Atsushi
Apr 17 at 20:19
C: ? It is a windows or Linux environment?
– JucaPirama
Apr 17 at 20:44
Are you using WSL?
– vidarlo
Apr 17 at 21:00
I use windows ubuntu
– Atsushi
Apr 17 at 21:04
1
Sorry. My mistake. You need to use forward slashes in the path, not backslashes. Anyway, my advice stands.
– vidarlo
Apr 17 at 22:08
|
show 4 more comments
You need to give full path to hello_time.py
.
Try
* * * * * /usr/bin/python /path/to/hello_time.py
Replace /path/to
with actual path for hello_time.py
. This you can get by running pwd
from the directory it's located in.
like this * * * * * /usr/bin/python C:Usersa.sakataDesktoppython_lessonhello_time.py ? but still no
– Atsushi
Apr 17 at 20:19
C: ? It is a windows or Linux environment?
– JucaPirama
Apr 17 at 20:44
Are you using WSL?
– vidarlo
Apr 17 at 21:00
I use windows ubuntu
– Atsushi
Apr 17 at 21:04
1
Sorry. My mistake. You need to use forward slashes in the path, not backslashes. Anyway, my advice stands.
– vidarlo
Apr 17 at 22:08
|
show 4 more comments
You need to give full path to hello_time.py
.
Try
* * * * * /usr/bin/python /path/to/hello_time.py
Replace /path/to
with actual path for hello_time.py
. This you can get by running pwd
from the directory it's located in.
You need to give full path to hello_time.py
.
Try
* * * * * /usr/bin/python /path/to/hello_time.py
Replace /path/to
with actual path for hello_time.py
. This you can get by running pwd
from the directory it's located in.
answered Apr 17 at 18:48
vidarlovidarlo
13.4k6 gold badges33 silver badges59 bronze badges
13.4k6 gold badges33 silver badges59 bronze badges
like this * * * * * /usr/bin/python C:Usersa.sakataDesktoppython_lessonhello_time.py ? but still no
– Atsushi
Apr 17 at 20:19
C: ? It is a windows or Linux environment?
– JucaPirama
Apr 17 at 20:44
Are you using WSL?
– vidarlo
Apr 17 at 21:00
I use windows ubuntu
– Atsushi
Apr 17 at 21:04
1
Sorry. My mistake. You need to use forward slashes in the path, not backslashes. Anyway, my advice stands.
– vidarlo
Apr 17 at 22:08
|
show 4 more comments
like this * * * * * /usr/bin/python C:Usersa.sakataDesktoppython_lessonhello_time.py ? but still no
– Atsushi
Apr 17 at 20:19
C: ? It is a windows or Linux environment?
– JucaPirama
Apr 17 at 20:44
Are you using WSL?
– vidarlo
Apr 17 at 21:00
I use windows ubuntu
– Atsushi
Apr 17 at 21:04
1
Sorry. My mistake. You need to use forward slashes in the path, not backslashes. Anyway, my advice stands.
– vidarlo
Apr 17 at 22:08
like this * * * * * /usr/bin/python C:Usersa.sakataDesktoppython_lessonhello_time.py ? but still no
– Atsushi
Apr 17 at 20:19
like this * * * * * /usr/bin/python C:Usersa.sakataDesktoppython_lessonhello_time.py ? but still no
– Atsushi
Apr 17 at 20:19
C: ? It is a windows or Linux environment?
– JucaPirama
Apr 17 at 20:44
C: ? It is a windows or Linux environment?
– JucaPirama
Apr 17 at 20:44
Are you using WSL?
– vidarlo
Apr 17 at 21:00
Are you using WSL?
– vidarlo
Apr 17 at 21:00
I use windows ubuntu
– Atsushi
Apr 17 at 21:04
I use windows ubuntu
– Atsushi
Apr 17 at 21:04
1
1
Sorry. My mistake. You need to use forward slashes in the path, not backslashes. Anyway, my advice stands.
– vidarlo
Apr 17 at 22:08
Sorry. My mistake. You need to use forward slashes in the path, not backslashes. Anyway, my advice stands.
– vidarlo
Apr 17 at 22:08
|
show 4 more comments
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1134730%2fpython-script-not-working-on-crontab%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
1) Is cron active? 2) Does your script work in a terminal? 3) Does cron find python and the file hello_time.py?
– muclux
Apr 17 at 18:49
1 crond not 2yes
– Atsushi
Apr 17 at 20:18