title: Restart a script after 6 minutes
body: <p>I want to make a <code>for</code> loop in Python which will restart itself after 6 minutes or until the loop has finish doing itself 500 times. </p>
  
  <p>Maybe there is a command which I can apply at the start of the script to make it restart after 6 minutes.</p>
  
  <p>My script is:</p>
  
  <pre><code>if len(sys.argv) &lt; 2:
      # something
      sys.exit()
  else:
      if sys.argv[1]=="help":
          # something
          sys.exit()
      else:
          print "start"
          if len(sys.argv)== 3:
              if sys.argv[2]=="safe":
                  set_safe()
          url = sys.argv[1]
          if url.count("/")==2:
              url = url + "/"
          m = re.search('http\://([^/]*)/?.*', url)
          host = m.group(1)
          for i in range(500):
              # something
  </code></pre>
  
  <p>How should I do it? </p>