i have read a lot of posts on this site on how to implement a python script as a service.
After fiddling around i am at the point that the service is started via systemctl (and running) but the script is doing nothing...
My config file in /etc/systemd/system/:
[Unit]
Description=tg Bot
[Service]
Type=simple
User=user
WorkingDirectory=/home/user/tg_onduty/
ExecStart=/usr/bin/python3 /home/user/tg_onduty/on_duty.py
Restart=always
[Install]
WantedBy=multi-user.target
Output:
user@server:~$ sudo service tg_onduty status
● tg_onduty.service - Telegram OnDuty Bot
Loaded: loaded (/etc/systemd/system/tg_onduty.service; enabled; vendor preset
Active: active (running) since Thu 2018-02-15 11:28:20 CET; 2min 17s ago
Main PID: 1538 (python3)
Tasks: 9
Memory: 17.7M
CPU: 351ms
CGroup: /system.slice/tg_onduty.service
└─1538 /usr/bin/python3 /home/user/tg_onduty/on_duty.py
I have read https://unix.stackexchange.com/questions/339638/difference-between-systemd-and-terminal-starting-program/339645#339645 and understand that running the script via systemctl is different than running via CLI (via CLI /usr/bin/python3 /home/user/tg_onduty/on_duty.py is working).
My question is now:
How can i trace or see whats going wrong or why the script seems to do nothing? Via Journalctl i only see: Feb 15 11:56:17 server systemd[1]: Started tg Bot.
Any help is appreciated.
Thanks,
David
Are you sure you script not running at all? try to put logs in your script to see if something inside the script doesn't work.