Skip to content

Instantly share code, notes, and snippets.

@tomfanning
Created March 27, 2018 16:49
Show Gist options
  • Save tomfanning/585434ebd29bffdd88bf693d033fae19 to your computer and use it in GitHub Desktop.
Save tomfanning/585434ebd29bffdd88bf693d033fae19 to your computer and use it in GitHub Desktop.
Installing a console app as a service in systemctl
echo "[Unit]
Description=My Service Name
[Service]
WorkingDirectory=$workingdir
ExecStart=$workingdir/binary-name
Restart=always
RestartSec=10 # Restart service after 10 seconds if it crashes
SyslogIdentifier=myservicename
User=root
Environment=\"ASPNETCORE_ENVIRONMENT=Production\"
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/myservicename.service
systemctl enable myservicename.service
systemctl start myservicename.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment