title: running python script as a systemd service
body: <p>I have a python script <code>myScript.py</code> which is writing on a file every 2 second. But when I want to run this script as a <code>systemd</code> service, service works but not writing on file.</p>
  
  <p>I created a <code>myscript.service</code> file on <code>/lib/systemd/system/</code>
  and designed as below:</p>
  
  <pre><code>[Unit]
  Description=My Script Service
  After=multi-user.target
  
  [Service]
  Type=idle
  ExecStart=/usr/bin/python /home/pala/PycharmProjects/myScript.py
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>and <code>myScript.py</code> is:</p>
  
  <pre><code>import time
  while True:
  
      with open("/home/pala/Documents/file.txt", "a") as myFile:
          myFile.write("--**--")
  
      time.sleep(2)
  </code></pre>