systemd service

テンプレート(一般ユーザ権限、bashrc使用)

[Unit]
Description=My Service
[Service]
Type=simple
User=user
Group=user
Restart=always
WorkingDirectory=WORKING_DIR
ExecStart=/bin/bash -c "COMMAND"
[Install]
WantedBy=multi-user.target
sudo ln -s my_service.service /etc/systemd/system/
sudo systemctl enable my_service
sudo systemctl restart my_service
# After you edit service file
sudo systemctl daemon-reload
# Check log
sudo systemctl status my_service

If you are using python, maybe you need to set environment PYTHONUNBUFFERED=1 to see log.

# In [Service] Section
Environment="PYTHONUNBUFFERED=1"
Environment="KEY=VALUE"