How to run init.d scripts on Windows WSL?
Windows Subsystem for Linux, as of May 2018 still doesn't support init.d
or systemd
service management, and I ran into issues with services and several options online, with non working optimally for all cases
windows-subsystem-for-linux
add a comment |
Windows Subsystem for Linux, as of May 2018 still doesn't support init.d
or systemd
service management, and I ran into issues with services and several options online, with non working optimally for all cases
windows-subsystem-for-linux
Is there a reason why you can't create a Windows service for them?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:42
@IgnacioVazquez-Abrams can you please provide an explanation to how that works?
– Olubodun Agbalaya
May 26 '18 at 13:45
As to how services on Windows work?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:46
As to how to create a service to run a Linux service/start up script from windows @IgnacioVazquez-Abrams
– Olubodun Agbalaya
May 26 '18 at 13:52
add a comment |
Windows Subsystem for Linux, as of May 2018 still doesn't support init.d
or systemd
service management, and I ran into issues with services and several options online, with non working optimally for all cases
windows-subsystem-for-linux
Windows Subsystem for Linux, as of May 2018 still doesn't support init.d
or systemd
service management, and I ran into issues with services and several options online, with non working optimally for all cases
windows-subsystem-for-linux
windows-subsystem-for-linux
edited May 26 '18 at 14:03
Anaksunaman
5,23821222
5,23821222
asked May 26 '18 at 13:40
Olubodun AgbalayaOlubodun Agbalaya
363
363
Is there a reason why you can't create a Windows service for them?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:42
@IgnacioVazquez-Abrams can you please provide an explanation to how that works?
– Olubodun Agbalaya
May 26 '18 at 13:45
As to how services on Windows work?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:46
As to how to create a service to run a Linux service/start up script from windows @IgnacioVazquez-Abrams
– Olubodun Agbalaya
May 26 '18 at 13:52
add a comment |
Is there a reason why you can't create a Windows service for them?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:42
@IgnacioVazquez-Abrams can you please provide an explanation to how that works?
– Olubodun Agbalaya
May 26 '18 at 13:45
As to how services on Windows work?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:46
As to how to create a service to run a Linux service/start up script from windows @IgnacioVazquez-Abrams
– Olubodun Agbalaya
May 26 '18 at 13:52
Is there a reason why you can't create a Windows service for them?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:42
Is there a reason why you can't create a Windows service for them?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:42
@IgnacioVazquez-Abrams can you please provide an explanation to how that works?
– Olubodun Agbalaya
May 26 '18 at 13:45
@IgnacioVazquez-Abrams can you please provide an explanation to how that works?
– Olubodun Agbalaya
May 26 '18 at 13:45
As to how services on Windows work?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:46
As to how services on Windows work?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:46
As to how to create a service to run a Linux service/start up script from windows @IgnacioVazquez-Abrams
– Olubodun Agbalaya
May 26 '18 at 13:52
As to how to create a service to run a Linux service/start up script from windows @IgnacioVazquez-Abrams
– Olubodun Agbalaya
May 26 '18 at 13:52
add a comment |
2 Answers
2
active
oldest
votes
The following bash script works for me.. Note the continue
operator is needed to skip scripts that fail, and the start
argument is needed by most service scripts.. i believe
for f in /etc/init.d/*; do sh "$f" start || continue; done ;
add a comment |
This is just a general direction (it is how I did it) - maybe someone can improve the idea.
Whenever LxssManager service is started (restarted) there are 2 entries in Event Viewer -> Windows Logs -> Security
Audit Success Sun 13.01.2019 13:34:52 Microsoft Windows security auditing. 4672 Special Logon
Audit Success Sun 13.01.2019 13:34:52 Microsoft Windows security auditing. 4624 Logon
If you right click the one with "Special logon" in task category column you can "Attach task to this event" with folowing actions (using Task Scheduler)
Program/script: C:WindowsSystem32wsl.exe and with Arguments: /usr/bin/apache.sh (or any other .sh file you have created)
On the linux side create .sh file to start your service within Linux (this is how I did it):
create apache.sh and put it into /usr/bin/
My apache.sh looks like:
#!/bin/sh
sudo service apache2 start
If your script requires linux authentication you can use
ubuntu config --default-user root (will set default user as root ) - run this from cmd.exe with admin privileges.
For more on this https://docs.microsoft.com/en-us/windows/wsl/user-support
This seems like nice automated hussle free method (at least to me)
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1326169%2fhow-to-run-init-d-scripts-on-windows-wsl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The following bash script works for me.. Note the continue
operator is needed to skip scripts that fail, and the start
argument is needed by most service scripts.. i believe
for f in /etc/init.d/*; do sh "$f" start || continue; done ;
add a comment |
The following bash script works for me.. Note the continue
operator is needed to skip scripts that fail, and the start
argument is needed by most service scripts.. i believe
for f in /etc/init.d/*; do sh "$f" start || continue; done ;
add a comment |
The following bash script works for me.. Note the continue
operator is needed to skip scripts that fail, and the start
argument is needed by most service scripts.. i believe
for f in /etc/init.d/*; do sh "$f" start || continue; done ;
The following bash script works for me.. Note the continue
operator is needed to skip scripts that fail, and the start
argument is needed by most service scripts.. i believe
for f in /etc/init.d/*; do sh "$f" start || continue; done ;
answered May 26 '18 at 13:44
Olubodun AgbalayaOlubodun Agbalaya
363
363
add a comment |
add a comment |
This is just a general direction (it is how I did it) - maybe someone can improve the idea.
Whenever LxssManager service is started (restarted) there are 2 entries in Event Viewer -> Windows Logs -> Security
Audit Success Sun 13.01.2019 13:34:52 Microsoft Windows security auditing. 4672 Special Logon
Audit Success Sun 13.01.2019 13:34:52 Microsoft Windows security auditing. 4624 Logon
If you right click the one with "Special logon" in task category column you can "Attach task to this event" with folowing actions (using Task Scheduler)
Program/script: C:WindowsSystem32wsl.exe and with Arguments: /usr/bin/apache.sh (or any other .sh file you have created)
On the linux side create .sh file to start your service within Linux (this is how I did it):
create apache.sh and put it into /usr/bin/
My apache.sh looks like:
#!/bin/sh
sudo service apache2 start
If your script requires linux authentication you can use
ubuntu config --default-user root (will set default user as root ) - run this from cmd.exe with admin privileges.
For more on this https://docs.microsoft.com/en-us/windows/wsl/user-support
This seems like nice automated hussle free method (at least to me)
add a comment |
This is just a general direction (it is how I did it) - maybe someone can improve the idea.
Whenever LxssManager service is started (restarted) there are 2 entries in Event Viewer -> Windows Logs -> Security
Audit Success Sun 13.01.2019 13:34:52 Microsoft Windows security auditing. 4672 Special Logon
Audit Success Sun 13.01.2019 13:34:52 Microsoft Windows security auditing. 4624 Logon
If you right click the one with "Special logon" in task category column you can "Attach task to this event" with folowing actions (using Task Scheduler)
Program/script: C:WindowsSystem32wsl.exe and with Arguments: /usr/bin/apache.sh (or any other .sh file you have created)
On the linux side create .sh file to start your service within Linux (this is how I did it):
create apache.sh and put it into /usr/bin/
My apache.sh looks like:
#!/bin/sh
sudo service apache2 start
If your script requires linux authentication you can use
ubuntu config --default-user root (will set default user as root ) - run this from cmd.exe with admin privileges.
For more on this https://docs.microsoft.com/en-us/windows/wsl/user-support
This seems like nice automated hussle free method (at least to me)
add a comment |
This is just a general direction (it is how I did it) - maybe someone can improve the idea.
Whenever LxssManager service is started (restarted) there are 2 entries in Event Viewer -> Windows Logs -> Security
Audit Success Sun 13.01.2019 13:34:52 Microsoft Windows security auditing. 4672 Special Logon
Audit Success Sun 13.01.2019 13:34:52 Microsoft Windows security auditing. 4624 Logon
If you right click the one with "Special logon" in task category column you can "Attach task to this event" with folowing actions (using Task Scheduler)
Program/script: C:WindowsSystem32wsl.exe and with Arguments: /usr/bin/apache.sh (or any other .sh file you have created)
On the linux side create .sh file to start your service within Linux (this is how I did it):
create apache.sh and put it into /usr/bin/
My apache.sh looks like:
#!/bin/sh
sudo service apache2 start
If your script requires linux authentication you can use
ubuntu config --default-user root (will set default user as root ) - run this from cmd.exe with admin privileges.
For more on this https://docs.microsoft.com/en-us/windows/wsl/user-support
This seems like nice automated hussle free method (at least to me)
This is just a general direction (it is how I did it) - maybe someone can improve the idea.
Whenever LxssManager service is started (restarted) there are 2 entries in Event Viewer -> Windows Logs -> Security
Audit Success Sun 13.01.2019 13:34:52 Microsoft Windows security auditing. 4672 Special Logon
Audit Success Sun 13.01.2019 13:34:52 Microsoft Windows security auditing. 4624 Logon
If you right click the one with "Special logon" in task category column you can "Attach task to this event" with folowing actions (using Task Scheduler)
Program/script: C:WindowsSystem32wsl.exe and with Arguments: /usr/bin/apache.sh (or any other .sh file you have created)
On the linux side create .sh file to start your service within Linux (this is how I did it):
create apache.sh and put it into /usr/bin/
My apache.sh looks like:
#!/bin/sh
sudo service apache2 start
If your script requires linux authentication you can use
ubuntu config --default-user root (will set default user as root ) - run this from cmd.exe with admin privileges.
For more on this https://docs.microsoft.com/en-us/windows/wsl/user-support
This seems like nice automated hussle free method (at least to me)
edited Jan 13 at 13:12
answered Jan 13 at 13:04
MishaMisha
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1326169%2fhow-to-run-init-d-scripts-on-windows-wsl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is there a reason why you can't create a Windows service for them?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:42
@IgnacioVazquez-Abrams can you please provide an explanation to how that works?
– Olubodun Agbalaya
May 26 '18 at 13:45
As to how services on Windows work?
– Ignacio Vazquez-Abrams
May 26 '18 at 13:46
As to how to create a service to run a Linux service/start up script from windows @IgnacioVazquez-Abrams
– Olubodun Agbalaya
May 26 '18 at 13:52