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

Is It normal to keep log file larger than data file?

What is the next number in the series: 21, 21, 23, 20, 5, 25, 31, 24,?

Why didn't Kes send Voyager home?

What does IKEA-like mean?

How to work with ElasticSearch in Mathematica?

Applications of schemes to mathematical physics

Why do previous versions of Debian packages vanish in the package repositories? (highly relevant for version-controlled system configuration)

Is having your hand in your pocket during a presentation bad?

What determines the top speed in ice skating?

Why did a young George Washington sign a document admitting to assassinating a French military officer?

Find the percentage

Can a Creature at 0 HP Take Damage?

Can massive damage kill you while at 0 HP?

QGIS can't detect negative values?

Relation between signal processing and control systems engineering?

What does ぎゃんかわ女子 mean?

Postman Delivery

Little Endian num 2 string conversion 🔃

How to find out which object is taking space?

How can I curtail abuse of the Illusion wizard's Illusory Reality feature?

how do you value what your leisure time is worth?

Rat proofing compost bin but allowing worms in

Meaning of A-infinity relations

Difference between $HOME and ~



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;









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 .










share|improve this question





















  • 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

















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 .










share|improve this question





















  • 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













0












0








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 .










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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












  • 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










1 Answer
1






active

oldest

votes


















3
















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.






share|improve this answer

























  • 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












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
);



);














draft saved

draft discarded
















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









3
















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.






share|improve this answer

























  • 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















3
















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.






share|improve this answer

























  • 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













3














3










3









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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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


















draft saved

draft discarded















































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.




draft saved


draft discarded














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





















































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

Tamil (spriik) Luke uk diar | Nawigatjuun

Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?