Answer the question
In order to leave comments, you need to log in
How to restart a service without entering a password?
There is a service:
[Unit]
Description=Example .NET Web API App running on Ubuntu
[Service]
WorkingDirectory=<Application path>
ExecStart=/usr/bin/dotnet <Application path><Name>.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
SyslogIdentifier=dotnet-example
User=<User>
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
I am logged into the system under the same user, but the creature still requires a password, how can this be bypassed in a bash script?
Answer the question
In order to leave comments, you need to log in
Since Alexei Cheremisin was not honored.
Add the following line to /etc/sudoers:
<username> ALL=(ALL) NOPASSWD: /bin/systemctl restart <service_name>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question