3/15 17:32 Addendum From here
You pointed out that / usr / lib / systemd / system / is where to put the services contained in the packages installed by the system.
As you pointed out, it seems to be better to put it under / etc / systemd / system /, so the following has been corrected. Thank you for pointing out!
3/15 17:32 Addendum
Will be added later. For the time being, a real memo.
Create a unit file like the one below in / etc / systemd / system with the file name "xxxxx.service".
[Unit]
Description=Sample Hogehoge Script
[Service]
ExecStart=/home/hogemi/fuga.py hikisu
Restart=always
Type=simple
PIDFile=/var/run/fuga.pid
[Install]
WantedBy=multi-user.target
In the examples of some of the ancestors found, there were many that had Type = forking, but this is the behavior on the script side that "when started, it terminates itself and leaves a child". Set Type = simple for scripts that stay in the foreground.
If the above unit file was created as fuga.service,
systemctl start fuga
The service starts with.
In the unit file mentioned earlier, if Type = simple is not set, systemctl itself will not end when the type that stays in the foreground is started. If Type = simple, systemctl will end properly when the command is issued.
More on that later.
Recommended Posts