cron not executing python3Addition to cron is not executedCron not call sh scriptCrontab or cron.d to run a...

Grade 10 Analytic Geometry Question 23- Incredibly hard

What's the most convenient time of year to end the world?

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

Why did other German political parties disband so fast when Hitler was appointed chancellor?

why a subspace is closed?

How to deal with an incendiary email that was recalled

What is better: yes / no radio, or simple checkbox?

Why does a metal block make a shrill sound but not a wooden block upon hammering?

Broken patches on a road

If I sold a PS4 game I owned the disc for, can I reinstall it digitally?

Does Improved Divine Smite trigger when a paladin makes an unarmed strike?

Slow moving projectiles from a hand-held weapon - how do they reach the target?

Why do members of Congress in committee hearings ask witnesses the same question multiple times?

Why is working on the same position for more than 15 years not a red flag?

Am I a Rude Number?

Can a dragon be stuck looking like a human?

What is the purpose of easy combat scenarios that don't need resource expenditure?

Explain the objections to these measures against human trafficking

How to prevent users from executing commands through browser URL

Book where aliens are selecting humans for food consumption

How do you funnel food off a cutting board?

How would one buy a used TIE Fighter or X-Wing?

What's a good word to describe a public place that looks like it wouldn't be rough?

Placing an adverb between a verb and an object?



cron not executing python3


Addition to cron is not executedCron not call sh scriptCrontab or cron.d to run a wav file. What am I doing wrong?Script not working with crontab, works manuallyPython script run from crontab does not recognize USB drive mounted laterCannot execute Python3 RPi.GPIO import from shell/rc.localAutomatically launching a script after full bootAutostarting a python script at boot not working in /etc/rc.local and systemdYA Cron QuestionHow to run a script which uses I/O's on startup?













0















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










share|improve this question



























    0















    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










    share|improve this question

























      0












      0








      0








      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










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 14 hours ago









      Dan B RaelinDan B Raelin

      257




      257






















          2 Answers
          2






          active

          oldest

          votes


















          5














          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 crontab (typically /usr/bin/python3 but it is also valid to use one installed elsewhere , e.g. a virtualenv directory)



          If your script or program relies on being in the same directory, make sure to change directory



          cd /path/to/dir && /usr/bin/python3 ./Example.py






          share|improve this answer


























          • Note shebangs are ignored when called script is called explicitly as argument to python

            – crasic
            14 hours ago











          • The script should also cd <relevant directory>.

            – Ingo
            11 hours ago











          • @Ingo this is not strictly necessary unless Example.py uses relative paths to CWD in it's logic, using the full path of the script is also acceptable in many instances. I will edit for completeness

            – crasic
            10 hours ago













          • Maybe, but I have seen many python scripts that cannot find its custom modules if not executed from its current directory.

            – Ingo
            10 hours ago











          • Is there a downside in just including the change directory when adding a .py in crontab? (for future reference on best practices)

            – Dan B Raelin
            8 hours ago



















          1














          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






          share|improve this answer








          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.
















          • 1





            The script should also cd <relevant directory>.

            – Ingo
            11 hours ago













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


          }
          });














          draft saved

          draft discarded


















          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









          5














          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 crontab (typically /usr/bin/python3 but it is also valid to use one installed elsewhere , e.g. a virtualenv directory)



          If your script or program relies on being in the same directory, make sure to change directory



          cd /path/to/dir && /usr/bin/python3 ./Example.py






          share|improve this answer


























          • Note shebangs are ignored when called script is called explicitly as argument to python

            – crasic
            14 hours ago











          • The script should also cd <relevant directory>.

            – Ingo
            11 hours ago











          • @Ingo this is not strictly necessary unless Example.py uses relative paths to CWD in it's logic, using the full path of the script is also acceptable in many instances. I will edit for completeness

            – crasic
            10 hours ago













          • Maybe, but I have seen many python scripts that cannot find its custom modules if not executed from its current directory.

            – Ingo
            10 hours ago











          • Is there a downside in just including the change directory when adding a .py in crontab? (for future reference on best practices)

            – Dan B Raelin
            8 hours ago
















          5














          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 crontab (typically /usr/bin/python3 but it is also valid to use one installed elsewhere , e.g. a virtualenv directory)



          If your script or program relies on being in the same directory, make sure to change directory



          cd /path/to/dir && /usr/bin/python3 ./Example.py






          share|improve this answer


























          • Note shebangs are ignored when called script is called explicitly as argument to python

            – crasic
            14 hours ago











          • The script should also cd <relevant directory>.

            – Ingo
            11 hours ago











          • @Ingo this is not strictly necessary unless Example.py uses relative paths to CWD in it's logic, using the full path of the script is also acceptable in many instances. I will edit for completeness

            – crasic
            10 hours ago













          • Maybe, but I have seen many python scripts that cannot find its custom modules if not executed from its current directory.

            – Ingo
            10 hours ago











          • Is there a downside in just including the change directory when adding a .py in crontab? (for future reference on best practices)

            – Dan B Raelin
            8 hours ago














          5












          5








          5







          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 crontab (typically /usr/bin/python3 but it is also valid to use one installed elsewhere , e.g. a virtualenv directory)



          If your script or program relies on being in the same directory, make sure to change directory



          cd /path/to/dir && /usr/bin/python3 ./Example.py






          share|improve this answer















          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 crontab (typically /usr/bin/python3 but it is also valid to use one installed elsewhere , e.g. a virtualenv directory)



          If your script or program relies on being in the same directory, make sure to change directory



          cd /path/to/dir && /usr/bin/python3 ./Example.py







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 3 hours ago









          Seamus

          2,4791220




          2,4791220










          answered 14 hours ago









          crasiccrasic

          2,301318




          2,301318













          • Note shebangs are ignored when called script is called explicitly as argument to python

            – crasic
            14 hours ago











          • The script should also cd <relevant directory>.

            – Ingo
            11 hours ago











          • @Ingo this is not strictly necessary unless Example.py uses relative paths to CWD in it's logic, using the full path of the script is also acceptable in many instances. I will edit for completeness

            – crasic
            10 hours ago













          • Maybe, but I have seen many python scripts that cannot find its custom modules if not executed from its current directory.

            – Ingo
            10 hours ago











          • Is there a downside in just including the change directory when adding a .py in crontab? (for future reference on best practices)

            – Dan B Raelin
            8 hours ago



















          • Note shebangs are ignored when called script is called explicitly as argument to python

            – crasic
            14 hours ago











          • The script should also cd <relevant directory>.

            – Ingo
            11 hours ago











          • @Ingo this is not strictly necessary unless Example.py uses relative paths to CWD in it's logic, using the full path of the script is also acceptable in many instances. I will edit for completeness

            – crasic
            10 hours ago













          • Maybe, but I have seen many python scripts that cannot find its custom modules if not executed from its current directory.

            – Ingo
            10 hours ago











          • Is there a downside in just including the change directory when adding a .py in crontab? (for future reference on best practices)

            – Dan B Raelin
            8 hours ago

















          Note shebangs are ignored when called script is called explicitly as argument to python

          – crasic
          14 hours ago





          Note shebangs are ignored when called script is called explicitly as argument to python

          – crasic
          14 hours ago













          The script should also cd <relevant directory>.

          – Ingo
          11 hours ago





          The script should also cd <relevant directory>.

          – Ingo
          11 hours ago













          @Ingo this is not strictly necessary unless Example.py uses relative paths to CWD in it's logic, using the full path of the script is also acceptable in many instances. I will edit for completeness

          – crasic
          10 hours ago







          @Ingo this is not strictly necessary unless Example.py uses relative paths to CWD in it's logic, using the full path of the script is also acceptable in many instances. I will edit for completeness

          – crasic
          10 hours ago















          Maybe, but I have seen many python scripts that cannot find its custom modules if not executed from its current directory.

          – Ingo
          10 hours ago





          Maybe, but I have seen many python scripts that cannot find its custom modules if not executed from its current directory.

          – Ingo
          10 hours ago













          Is there a downside in just including the change directory when adding a .py in crontab? (for future reference on best practices)

          – Dan B Raelin
          8 hours ago





          Is there a downside in just including the change directory when adding a .py in crontab? (for future reference on best practices)

          – Dan B Raelin
          8 hours ago













          1














          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






          share|improve this answer








          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.
















          • 1





            The script should also cd <relevant directory>.

            – Ingo
            11 hours ago


















          1














          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






          share|improve this answer








          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.
















          • 1





            The script should also cd <relevant directory>.

            – Ingo
            11 hours ago
















          1












          1








          1







          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






          share|improve this answer








          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







          share|improve this answer








          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.









          share|improve this answer



          share|improve this answer






          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 12 hours 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.








          • 1





            The script should also cd <relevant directory>.

            – Ingo
            11 hours ago
















          • 1





            The script should also cd <relevant directory>.

            – Ingo
            11 hours ago










          1




          1





          The script should also cd <relevant directory>.

          – Ingo
          11 hours ago







          The script should also cd <relevant directory>.

          – Ingo
          11 hours ago




















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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

          Fairchild Swearingen Metro Inhaltsverzeichnis Geschichte | Innenausstattung | Nutzung | Zwischenfälle...

          Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...

          Marineschifffahrtleitung Inhaltsverzeichnis Geschichte | Heutige Organisation der NATO | Nationale und...