Let’s say you wish to have a process running in the background on Linux. You can define a service and run it using Systemd
[Unit]
Description=My test service
After=multi-user.target
[Service]
Type=simple
Restart=always
ExecStart=path_to_python script.py
[Install]
WantedBy=multi-user.target
/etc/systemd/system
sudo systemctl enable xfly_scheduler.service
sudo systemctl start xfly_scheduler.service
sudo journalctl -u xfly_scheduler.service