In directory /lib/systemd/system
, I created a file XYZ.service.
When running systemctl start XYZ
, it doesn't return. I had to do Ctrl-C to come out the command. Wonder why.
Interestingly, after I typed Ctrl-C. I can access the service XYZ.
Any idea what I did wrong? Thanks.
Here is the file XYZ.service
[Unit]
Description=XYZ
After=network.target
[Service]
Type=forking
ExecStart=/var/www/html/XYZ/ctrler
[Install]
WantedBy=multi-user.target
Most likely, your command isn't forking, sometimes called daemonizing. You said Type=forking
which means that the command is supposed to do a fork() and let the parent return when things are set up and the service is up and running. Your systemctl
command is waiting for this to happen.
If the command runs without forking, you can tell systemd
this by setting Type=simple
.
See the manual page for systemd.service for further details on the Type
configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With