I have a python script `myScript.py` which is writing on a file every 2 second. But when I want to run this script as a `systemd` service, service works but not writing on file.

I created a `myscript.service` file on `/lib/systemd/system/`
and designed as below:

```
[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

```

and `myScript.py` is:

```
import time
while True:

    with open("/home/pala/Documents/file.txt", "a") as myFile:
        myFile.write("--**--")

    time.sleep(2)

```