Saltar al contenido
danielsanjuan

Cuaderno · 14 de noviembre de 2026

Raspberry Pi: convertir un script en un servicio

raspberrysystemd

Que tu script arranque solo y se reinicie si se cae.

En /etc/systemd/system/mi-bot.service:

[Unit]
Description=Mi bot
After=network-online.target
Wants=network-online.target

[Service]
WorkingDirectory=/home/pi/mi-bot
ExecStart=/home/pi/mi-bot/.venv/bin/python app.py
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now mi-bot
journalctl -u mi-bot -f

Restart=always lo levanta solo si se cae. Para enterarte cuando eso pasa, un monitor tipo Uptime Kuma que avise por Telegram.

← Todas las notas