Systemctl
systemctl¶
Article for enabling systemd and systemctl in wsl
Linux Service states:¶
- installed (binary/configuration in place)
- enabled/disabled (to start on reboot)
- started/stopped (currently running or not)
Starting and Stopping Services¶
sudo systemctl start application
sudo systemctl stop application.service
sudo systemctl restart application.service
If the application in question is able to reload its configuration files (without restarting), you can issue the reload
command to initiate that process:
sudo systemctl reload application.service
Enabling and Disabling Services¶
sudo systemctl enable application.service
sudo systemctl disable application.service
This will create a symbolic link from the system’s copy of the service file (usually in /lib/systemd/system
or /etc/systemd/system
) into the location on disk where systemd
looks for autostart files (usually /etc/systemd/system/some_target.target.wants
.
Checking the Status of Services¶
systemctl status application.service
Creating .service and .socket files¶
[Unit]
Description=description
Requires=service-name.socket
After=network.target
[Service]
Type=simple
User=user
WorkingDirectory=/root/to/script
ExecStart=execution command
[Install]
WantedBy=multi-user.target
[Unit]
Description=description
[Socket]
ListenStream=/run/service-name.sock
[Install]
WantedBy=sockets.target