systemd: how to enable a service automatically from the first boot?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am using systemd to handle some tasks and I have a service file which works fine once enabled with systemctl.
Now, I would like to enable it automatically from the first boot.
I know that putting a replacement file into /etc/systemd/system/
replaces the behavior of the file with the same name into /lib/systemd/system/
.
There is a way to enable a service file automatically just to putting it in some directory ?
systemd
add a comment |Â
up vote
0
down vote
favorite
I am using systemd to handle some tasks and I have a service file which works fine once enabled with systemctl.
Now, I would like to enable it automatically from the first boot.
I know that putting a replacement file into /etc/systemd/system/
replaces the behavior of the file with the same name into /lib/systemd/system/
.
There is a way to enable a service file automatically just to putting it in some directory ?
systemd
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using systemd to handle some tasks and I have a service file which works fine once enabled with systemctl.
Now, I would like to enable it automatically from the first boot.
I know that putting a replacement file into /etc/systemd/system/
replaces the behavior of the file with the same name into /lib/systemd/system/
.
There is a way to enable a service file automatically just to putting it in some directory ?
systemd
I am using systemd to handle some tasks and I have a service file which works fine once enabled with systemctl.
Now, I would like to enable it automatically from the first boot.
I know that putting a replacement file into /etc/systemd/system/
replaces the behavior of the file with the same name into /lib/systemd/system/
.
There is a way to enable a service file automatically just to putting it in some directory ?
systemd
systemd
asked Jan 28 '16 at 16:43
simozz
19912
19912
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
1
down vote
sudo systemctl enable <service-name>
will enable service at boot time.
http://www.dynacont.net/documentation/linux/Useful_SystemD_commands/ has a list of useful commands. And there's always man systemctl
and man systemd
.
1
Note that you need at least the statementWantedBy=multi-user.target
under[Install]
in the unit file for it to start on boot in addition to enabling it via systemctl, otherwise the enable command won't do anything.
â Mahn
Jul 13 '16 at 0:45
add a comment |Â
up vote
0
down vote
You could use systems.preset for default enabled units.
Systems.preset allows to configure set of units to be enabled/disabled
vendor preset
in systemctl status unit
refers to this.
For more info how use this refer linked man page
add a comment |Â
up vote
0
down vote
IMPORTANT NOTE: The following works for me under Ubuntu. It should work as is under Debian. RPM based distros prevent the auto-start by default, but it may still get your closer to your goal.
In most case, you want to install it in the multi-user.target
using the install section as follow:
[Install]
WantedBy=multi-user.target
This means the your-package.postinst
script will automatically start the daemon for you.
Note that if you have your own your-package.postinst
script, you have to make sure to include the Debian helper as in:
#!/bin/sh
#DEBHELPER#
...your own script here...
Without the #DEBHELPER#
pattern, the packager will not add the default code and as a result your daemon won't get enabled and started automatically. The code added there will enable and start the service:
systemctl enable <service-name>
systemctl start <service-name>
unless the service is static
(does not have an [Install]
section as shown above.) A static service requires a special command line to be enabled and that's not available by default:
systemctl add-wants multi-user.target <service-name>
As we can see, the command includes multi-user.target
which the default #DEBHELPER#
(systemd, really) has no clue about unless you have an [Install]
section.
The package must also be built with the systemd
extension. This means having the following in your debian/rules
file:
%:
dh $@ --with systemd --parallel
That should get you set.
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
sudo systemctl enable <service-name>
will enable service at boot time.
http://www.dynacont.net/documentation/linux/Useful_SystemD_commands/ has a list of useful commands. And there's always man systemctl
and man systemd
.
1
Note that you need at least the statementWantedBy=multi-user.target
under[Install]
in the unit file for it to start on boot in addition to enabling it via systemctl, otherwise the enable command won't do anything.
â Mahn
Jul 13 '16 at 0:45
add a comment |Â
up vote
1
down vote
sudo systemctl enable <service-name>
will enable service at boot time.
http://www.dynacont.net/documentation/linux/Useful_SystemD_commands/ has a list of useful commands. And there's always man systemctl
and man systemd
.
1
Note that you need at least the statementWantedBy=multi-user.target
under[Install]
in the unit file for it to start on boot in addition to enabling it via systemctl, otherwise the enable command won't do anything.
â Mahn
Jul 13 '16 at 0:45
add a comment |Â
up vote
1
down vote
up vote
1
down vote
sudo systemctl enable <service-name>
will enable service at boot time.
http://www.dynacont.net/documentation/linux/Useful_SystemD_commands/ has a list of useful commands. And there's always man systemctl
and man systemd
.
sudo systemctl enable <service-name>
will enable service at boot time.
http://www.dynacont.net/documentation/linux/Useful_SystemD_commands/ has a list of useful commands. And there's always man systemctl
and man systemd
.
answered Jan 28 '16 at 17:33
Munir
2,097419
2,097419
1
Note that you need at least the statementWantedBy=multi-user.target
under[Install]
in the unit file for it to start on boot in addition to enabling it via systemctl, otherwise the enable command won't do anything.
â Mahn
Jul 13 '16 at 0:45
add a comment |Â
1
Note that you need at least the statementWantedBy=multi-user.target
under[Install]
in the unit file for it to start on boot in addition to enabling it via systemctl, otherwise the enable command won't do anything.
â Mahn
Jul 13 '16 at 0:45
1
1
Note that you need at least the statement
WantedBy=multi-user.target
under [Install]
in the unit file for it to start on boot in addition to enabling it via systemctl, otherwise the enable command won't do anything.â Mahn
Jul 13 '16 at 0:45
Note that you need at least the statement
WantedBy=multi-user.target
under [Install]
in the unit file for it to start on boot in addition to enabling it via systemctl, otherwise the enable command won't do anything.â Mahn
Jul 13 '16 at 0:45
add a comment |Â
up vote
0
down vote
You could use systems.preset for default enabled units.
Systems.preset allows to configure set of units to be enabled/disabled
vendor preset
in systemctl status unit
refers to this.
For more info how use this refer linked man page
add a comment |Â
up vote
0
down vote
You could use systems.preset for default enabled units.
Systems.preset allows to configure set of units to be enabled/disabled
vendor preset
in systemctl status unit
refers to this.
For more info how use this refer linked man page
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You could use systems.preset for default enabled units.
Systems.preset allows to configure set of units to be enabled/disabled
vendor preset
in systemctl status unit
refers to this.
For more info how use this refer linked man page
You could use systems.preset for default enabled units.
Systems.preset allows to configure set of units to be enabled/disabled
vendor preset
in systemctl status unit
refers to this.
For more info how use this refer linked man page
answered Feb 14 '17 at 15:41
AbdulKareem
1011
1011
add a comment |Â
add a comment |Â
up vote
0
down vote
IMPORTANT NOTE: The following works for me under Ubuntu. It should work as is under Debian. RPM based distros prevent the auto-start by default, but it may still get your closer to your goal.
In most case, you want to install it in the multi-user.target
using the install section as follow:
[Install]
WantedBy=multi-user.target
This means the your-package.postinst
script will automatically start the daemon for you.
Note that if you have your own your-package.postinst
script, you have to make sure to include the Debian helper as in:
#!/bin/sh
#DEBHELPER#
...your own script here...
Without the #DEBHELPER#
pattern, the packager will not add the default code and as a result your daemon won't get enabled and started automatically. The code added there will enable and start the service:
systemctl enable <service-name>
systemctl start <service-name>
unless the service is static
(does not have an [Install]
section as shown above.) A static service requires a special command line to be enabled and that's not available by default:
systemctl add-wants multi-user.target <service-name>
As we can see, the command includes multi-user.target
which the default #DEBHELPER#
(systemd, really) has no clue about unless you have an [Install]
section.
The package must also be built with the systemd
extension. This means having the following in your debian/rules
file:
%:
dh $@ --with systemd --parallel
That should get you set.
add a comment |Â
up vote
0
down vote
IMPORTANT NOTE: The following works for me under Ubuntu. It should work as is under Debian. RPM based distros prevent the auto-start by default, but it may still get your closer to your goal.
In most case, you want to install it in the multi-user.target
using the install section as follow:
[Install]
WantedBy=multi-user.target
This means the your-package.postinst
script will automatically start the daemon for you.
Note that if you have your own your-package.postinst
script, you have to make sure to include the Debian helper as in:
#!/bin/sh
#DEBHELPER#
...your own script here...
Without the #DEBHELPER#
pattern, the packager will not add the default code and as a result your daemon won't get enabled and started automatically. The code added there will enable and start the service:
systemctl enable <service-name>
systemctl start <service-name>
unless the service is static
(does not have an [Install]
section as shown above.) A static service requires a special command line to be enabled and that's not available by default:
systemctl add-wants multi-user.target <service-name>
As we can see, the command includes multi-user.target
which the default #DEBHELPER#
(systemd, really) has no clue about unless you have an [Install]
section.
The package must also be built with the systemd
extension. This means having the following in your debian/rules
file:
%:
dh $@ --with systemd --parallel
That should get you set.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
IMPORTANT NOTE: The following works for me under Ubuntu. It should work as is under Debian. RPM based distros prevent the auto-start by default, but it may still get your closer to your goal.
In most case, you want to install it in the multi-user.target
using the install section as follow:
[Install]
WantedBy=multi-user.target
This means the your-package.postinst
script will automatically start the daemon for you.
Note that if you have your own your-package.postinst
script, you have to make sure to include the Debian helper as in:
#!/bin/sh
#DEBHELPER#
...your own script here...
Without the #DEBHELPER#
pattern, the packager will not add the default code and as a result your daemon won't get enabled and started automatically. The code added there will enable and start the service:
systemctl enable <service-name>
systemctl start <service-name>
unless the service is static
(does not have an [Install]
section as shown above.) A static service requires a special command line to be enabled and that's not available by default:
systemctl add-wants multi-user.target <service-name>
As we can see, the command includes multi-user.target
which the default #DEBHELPER#
(systemd, really) has no clue about unless you have an [Install]
section.
The package must also be built with the systemd
extension. This means having the following in your debian/rules
file:
%:
dh $@ --with systemd --parallel
That should get you set.
IMPORTANT NOTE: The following works for me under Ubuntu. It should work as is under Debian. RPM based distros prevent the auto-start by default, but it may still get your closer to your goal.
In most case, you want to install it in the multi-user.target
using the install section as follow:
[Install]
WantedBy=multi-user.target
This means the your-package.postinst
script will automatically start the daemon for you.
Note that if you have your own your-package.postinst
script, you have to make sure to include the Debian helper as in:
#!/bin/sh
#DEBHELPER#
...your own script here...
Without the #DEBHELPER#
pattern, the packager will not add the default code and as a result your daemon won't get enabled and started automatically. The code added there will enable and start the service:
systemctl enable <service-name>
systemctl start <service-name>
unless the service is static
(does not have an [Install]
section as shown above.) A static service requires a special command line to be enabled and that's not available by default:
systemctl add-wants multi-user.target <service-name>
As we can see, the command includes multi-user.target
which the default #DEBHELPER#
(systemd, really) has no clue about unless you have an [Install]
section.
The package must also be built with the systemd
extension. This means having the following in your debian/rules
file:
%:
dh $@ --with systemd --parallel
That should get you set.
answered Aug 23 at 18:44
Alexis Wilke
854614
854614
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f258316%2fsystemd-how-to-enable-a-service-automatically-from-the-first-boot%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password