Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are on the right track. To fire a python script every <em>n</em> hours, do this:</p> <pre><code>* */n * * * python /home/pi/Desktop/myProg.py </code></pre> <p>That's it. Make sure that you are editing the sudo level crontab, which is accessed via <code>sudo crontab -e</code>.</p> <p>Your code would actually have the script run at 2 am every day - it technically says "run whenever the hour is equal to <code>2</code>". <code>* */n * * *</code> says "run whenever the hour is divisible by <code>n</code>". A GREAT resource on crontab can be found here: <a href="http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/" rel="nofollow noreferrer">Schedule tasks on Linux using crontab</a></p> <p>Logging the output is also easy. If you had a log file on your desktop called myLog.log, you would add <code>&gt;&gt; /home/pi/Desktop/myLog.log</code> to end of the crontab entry. That would make the entry look like this:</p> <pre><code>* */2 * * * python /home/pi/Desktop/myProg.py &gt;&gt; /home/pi/Desktop/myLog.log </code></pre> <p><strong>EDIT</strong> (thanks to @Iamreck): Another option for outputting to a file is with sys.stdout. This would accomplish the same goal. To do it this way, add the following to your Python script:</p> <pre><code>import sys sys.stdout = open("myLog.log","w") sys.stderr = open("myLogErr.log","w") print "stdout test" </code></pre> <p>You would also have to change the working directory to your Desktop when doing this, and this can be done with the top answer at <a href="https://stackoverflow.com/questions/1432924/python-change-the-scripts-working-directory-to-the-scripts-own-directory">this SO post</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload