Как ограничить использование памяти процессом во время его работы?

Sus definiciones de servicio son así:

[Service]
ExecStart=python /home/pi/projects/script1.py
Restart=always

Y este es el mensaje de error en cada uno de ellos:

Executable path is not absolute, ignoring: python /home/pi/...

Para systemd, el "ejecutable" en esta definición de servicio es python, y claramente no es una ruta absoluta. El /home/pi/projects/script1.pyes solo un argumento para este pythonejecutable, y el trabajo del ejecutable es cuidar su forma adecuada.

Cualquier variable de entorno específica de Python -como PYTHONPATHno tiene ningún significado parasystemd:usted debe darle una ruta absoluta para el ejecutable en la definición del servicio, todas y cada una de las veces.

Por lo general, la ruta absoluta al intérprete de python es /usr/bin/python, pero puede verificar:

$ type python
python is /usr/bin/python

Entonces sus definiciones de servicio deberían ser así:

[Service]
ExecStart=/usr/bin/python /home/pi/projects/script1.py
Restart=always

Puede encontrar una introducción muy útil a systemd aquí. Obtiene y mantiene un bot de Telegram ejecutándose como un script de Python.

1
06.03.2019, 08:05
2 ответа

Если process_aне использует активно память, она будет выгружена при запуске process_b.

Таким образом, если вы не видите, что память process_aвыгружена, это может быть связано с тем, что process_aактивно использует память.

Итак, как вы можете заставить process_aбыть неактивным какое-то время?

Вы приостанавливаете его.

kill -TSTP $pid

Затем вы запускаете process_bи позволяете process_aперейти к обмену.

Если вы хотите выделить больше памяти для подкачки, проверьте:https://gitlab.com/ole.tange/tangetools/tree/master/swapout

Наконец, когда process_bвыполнено, вы отпускаете тормоз на process_a:

.
kill -CONT $pid
2
28.04.2021, 23:36
Check for the priority of the process

Higher priority is -20
lower prioritty is +19
Neutral is 0

if process_a is having highher priority based on your requirement reduce the priority (-20 to +19). Higher the priority it will consumes most of resources


You can try with ulimit command options too
-1
28.04.2021, 23:36

Теги

Похожие вопросы