/etc/systemd/system/pyfilebrowser.serviceContents
[Unit]
Description=PyFilebrowser Service
After=network-online.target
[Service]
Type=simple
WorkingDirectory=/home/vicky/pyfilebrowser
ExecStart=/home/vicky/pyfilebrowser/venv/bin/python /home/vicky/pyfilebrowser/temp.py
User=vicky
Group=vicky
Environment="PATH=/home/vicky/pyfilebrowser/venv/bin:$PATH"
StandardOutput=append:/var/log/pyfilebrowser/output.log
StandardError=append:/var/log/pyfilebrowser/error.log
[Install]
WantedBy=multi-user.target
UserandGroupare not required if the permissions to the files are changed towww-data
Since that involves changing permissions even for modules withinvenv, it is simpler to run as user
sudo systemctl enable pyfilebrowser.servicesudo systemctl daemon-reloadsudo systemctl start pyfilebrowser.service[OR]
sudo service pyfilebrowser startsudo systemctl status pyfilebrowser.service[OR]
sudo service pyfilebrowser statussudo systemctl stop pyfilebrowser.service[OR]
sudo service pyfilebrowser stopjournalctl -u pyfilebrowser.service