I am trying to run python file with arguments from systemd service. So the service file supposed to take argument and pass it to python file in "Execstart".
Here is my systemd file:
[Unit]
Description=test Service On %I
After=multi-user.target
[Service]
WorkingDirectory=/home/user_name/directory
User=user_name
Type=idle
ExecStart=/usr/bin/python3 /home/user_name/directory/test.py %I
Restart=no
[Install]
WantedBy=multi-user.target
test.py:
import sys
print("arguments: "+str(sys.argv))
I tried with following commands:
sudo systemctl start $(systemd-escape --template [email protected] "arg1")
also,
sudo systemctl start [email protected]
I get error: Unit [email protected] not found
/etc/systemd/system
. Try:sudo cp /path/to/[email protected] /etc/systemd/system