title: Permissions Error and No such file or Directory
body: <pre><code>if not os.path.exists('/var/log/'):
      os.makedirs('/var/log/')
  print(log_filepath)
  os.chmod(log_filepath, stat.S_IWOTH)
  
  f_log_in = open(log_filepath, &quot;a&quot;)
  </code></pre>
  <p>Without the chmod command, it will throw an error saying permission denied for the f_log_in file open command.</p>
  <pre><code>    f_log_in = open(log_filepath, &quot;a&quot;)
  PermissionError: [Errno 13] Permission denied: '/var/log/s3_sync.log'
  </code></pre>
  <p>When I include the os.chmod command, it says:</p>
  <pre><code>   os.chmod(log_filepath, stat.S_IWOTH)
  FileNotFoundError: [Errno 2] No such file or directory: '/var/log/s3_sync.log'
  </code></pre>
  <p>Are there any other ways of approaching this?</p>
  <p>EDIT: THIS IS NOT A DUPLICATE, I DELETED THE OTHER ONE.</p>