Reputation: 5069
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
Upvotes: 10
Views: 7537
Reputation: 381
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.
Upvotes: 15