title: set a Python program to expire after a certain number of days
body: <p>Say I wanted to implement a 30-day trial or run a 5-day beta test. How would I go about this using Python? The idea is that the program stops working and prints a message to the user that the program has expired after said amount of time. I thought about doing it this way.</p>
  
  <pre><code>import sys
  import time
  start = time.time
  expire = start + 2592000
  while True:
      Run Program
      if time.time &gt; start + expire:
          sys.exit("This program has now expired")
  </code></pre>
  
  <p>The problem with this is that the program would have to be constantly running on the user's machine for the specified amount of time. There must be a simpler or more sensible way to go about it, like having the program check at startup if a certain number of days has been reached. Thanks in advance for your input on this.</p>
  
  <p>Update</p>
  
  <p>I just thought of another way of doing this. Would this work?</p>
  
  <pre><code>import datetime
  import sys
  
  start = datetime.datetime.now()
  expire = start.month + 1
  while True:
      Run Program
      if datetime.datetime.now().month == expire:
          sys.exit("Your 1 month trial has expired.")
  </code></pre>