Answer the question
In order to leave comments, you need to log in
How to change PATH in debian .service?
Prepared website.service service:
[Unit]
Description=web site
After=network.target
[Service]
User=mf
Group=sudo
Type=simple
Restart=on-abort
RestartSec=5s
WorkingDirectory=/home/website
Environment=PATH=/home/mf/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ExecStartPre=/bin/sh -c "systemctl set-environment PATH=/home/mf/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ExecStart=/bin/bash -c 'PATH=/home/mf/node_modules/.bin:$PATH exec sudo ./website'
[Install]
WantedBy=multi-user.target
fmt.Println(os.Getenv("PATH")) // /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PATH="/home/mf/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question