@leonidvoroninthebest

Permission Denied:[Errno 13] на линукс при попытке запустить скрипт как сервис — как исправить?

Не получается никак запустить скрипт как сервис через systemd - если в скрипте есть обращение к чтению/записи в файл, возникает данная ошибка. Как исправить?
Job for test.service failed because the control process exited with error code.
See "systemctl status test.service" and "journalctl -xe" for details.
roman@romanubt20:~/Desktop$ journalctl -xe
Hint: You are currently not seeing messages from other users and the system.
      Users in groups 'adm', 'systemd-journal' can see all messages.
      Pass -q to turn off this notice.
мар 03 08:47:28 romanubt20 python3[703255]:   File "/opt/test_write/test.py", line 4, in <>
мар 03 08:47:28 romanubt20 python3[703255]:     with open("timestamp.txt", "a") as f:
мар 03 08:47:28 romanubt20 python3[703255]: PermissionError: [Errno 13] Permission denied:>
мар 03 09:20:22 romanubt20 python3[703367]: Traceback (most recent call last):
мар 03 09:20:22 romanubt20 python3[703367]:   File "/opt/test_write/test.py", line 4, in <>
мар 03 09:20:22 romanubt20 python3[703367]:     with open("timestamp.txt", "a") as f:
мар 03 09:20:22 romanubt20 python3[703367]: PermissionError: [Errno 13] Permission denied:>
мар 03 09:20:23 romanubt20 python3[703381]: Traceback (most recent call last):
мар 03 09:20:23 romanubt20 python3[703381]:   File "/opt/test_write/test.py", line 4, in <>
мар 03 09:20:23 romanubt20 python3[703381]:     with open("timestamp.txt", "a") as f:
мар 03 09:20:23 romanubt20 python3[703381]: PermissionError: [Errno 13] Permission denied:>
мар 03 09:20:24 romanubt20 python3[703384]: Traceback (most recent call last):
мар 03 09:20:24 romanubt20 python3[703384]:   File "/opt/test_write/test.py", line 4, in <>
мар 03 09:20:24 romanubt20 python3[703384]:     with open("timestamp.txt", "a") as f:
мар 03 09:20:24 romanubt20 python3[703384]: PermissionError: [Errno 13] Permission denied:>
мар 03 09:20:25 romanubt20 python3[703390]: Traceback (most recent call last):
мар 03 09:20:25 romanubt20 python3[703390]:   File "/opt/test_write/test.py", line 4, in <>
мар 03 09:20:25 romanubt20 python3[703390]:     with open("timestamp.txt", "a") as f:
мар 03 09:20:25 romanubt20 python3[703390]: PermissionError: [Errno 13] Permission denied:>
мар 03 09:20:26 romanubt20 python3[703393]: Traceback (most recent call last):
мар 03 09:20:26 romanubt20 python3[703393]:   File "/opt/test_write/test.py", line 4, in <>
мар 03 09:20:26 romanubt20 python3[703393]:     with open("timestamp.txt", "a") as f:
мар 03 09:20:26 romanubt20 python3[703393]: PermissionError: [Errno 13] Permission denied:>
lines 1065-1087/1087 (END)
  • Вопрос задан
  • 190 просмотров
Решения вопроса 1
@leonidvoroninthebest Автор вопроса
Нашел решение: в файле скрипта нужно было указать абсолютный путь в названии файла.
with open('/test_csv/text'+str(i)+'.txt', 'w') as f:
    f.write('Create a new text file!')<code>
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы