i have a problem with a systemd service and i cant find the problem.
I have script in the directory /home/username/test/ called battery.sh:
#!/bin/sh
max=99999
for i in `seq 1 $max`
do
clear
python3 batterie.py
sleep 5
done
it starts a python script named batterie.py. This script gives out a log file in the directory. I want the sh script to be autostarted, so i added batterie.service in /etc/systemd/system:
[Unit]
Description=Batterie Script
[Service]
Type=simple
ExecStart=/bin/sh /home/username/test/batterie.sh
WorkingDirectory=/home/username/test
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Then i added service to autostart with "sudo systemctl enable batterie". Now systemctl status batterie gives:
batterie.service - Batterie Script
Loaded: loaded (/etc/systemd/system/batterie.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-03-16 17:58:13 CET; 2min 17s ago
Main PID: 1117 (sh)
Tasks: 3 (limit: 18943)
Memory: 45.3M
CGroup: /system.slice/batterie.service
├─1117 /bin/sh /home/username/test/batterie.sh
└─1123 python3.10 batterie.py
Mär 16 18:00:21 NUC8i3BEK sh[1263]: TERM environment variable not set.
But there is no logfile in the directory test. But there is a log file when i start the script manually from the directory.
What did i do wrong?