I am creating a custom systemd service script that works fine. However I would like to execute a custom script when:
sudo systemsctl enable myservice.service
is executed.
Is this possible?
I am creating a custom systemd service script that works fine. However I would like to execute a custom script when:
sudo systemsctl enable myservice.service
is executed.
Is this possible?
As documented in
man systemd.unit
, there is no facility to run custom commands when a service is enabled. There are some possible alternate designs:enable
command on one line and your customer script on the second line.started
instead ofenabled
. Directives likeExecStartPre=
andExecSTartPost=
could help with that.