Start service before user logs in

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm running a debian 4.8.4-1 x64 vanilla on a VirtualBox VM on a Win 7 x64 host. Purpose of the installation is to serve as a server for the subsonic music streaming service, which offers a webinterface on port 4040. The service runs as user 'subsonic', which is a standard user which can login, and has a home dir (not sure if this matters.)



When I start the VM from the windows host, the machine boots up and gives me a login prompt. At this point, I can access the apache webserver on port 80 from other machines, but I cannot access the subsonic service on port 4040. As soon as I login the subsonic user, the subsonic service is available.



Obviously, the subsonic service is only started after the user logs in, while apache starts before the login. What is the difference, and how do I set the subsonic service to start up before login? Is this even the right approach, or should I log in the user automatically instead?



I'm looking for a way that works, and preferrably is idiomatic to the linux philosophy.










share|improve this question























  • Where is the service file that starts this service located? If it's in any user directory mentioned in systemd.unit(5), then the service will start after the user logs in.
    – saiarcot895
    Aug 2 '15 at 15:19










  • Thank you! I tried googling but I can't put the pieces together yet. How do I check that, and how do I change it - just move the service file? At what point are these service files created? By default the service runs as root, I changed that, but I did not change any service files...
    – phi
    Aug 2 '15 at 15:40










  • How did you install subsonic and how did you configure it to start automatically?
    – Gilles
    Aug 2 '15 at 18:21










  • I installed the deb-package with dpkg. The config in /etc/default/subsonic allows to specify a user to run the service. The startup file in /etc/init.d/ parses that file and starts the service with that user via start-stop-daemon.
    – phi
    Aug 3 '15 at 0:42














up vote
0
down vote

favorite












I'm running a debian 4.8.4-1 x64 vanilla on a VirtualBox VM on a Win 7 x64 host. Purpose of the installation is to serve as a server for the subsonic music streaming service, which offers a webinterface on port 4040. The service runs as user 'subsonic', which is a standard user which can login, and has a home dir (not sure if this matters.)



When I start the VM from the windows host, the machine boots up and gives me a login prompt. At this point, I can access the apache webserver on port 80 from other machines, but I cannot access the subsonic service on port 4040. As soon as I login the subsonic user, the subsonic service is available.



Obviously, the subsonic service is only started after the user logs in, while apache starts before the login. What is the difference, and how do I set the subsonic service to start up before login? Is this even the right approach, or should I log in the user automatically instead?



I'm looking for a way that works, and preferrably is idiomatic to the linux philosophy.










share|improve this question























  • Where is the service file that starts this service located? If it's in any user directory mentioned in systemd.unit(5), then the service will start after the user logs in.
    – saiarcot895
    Aug 2 '15 at 15:19










  • Thank you! I tried googling but I can't put the pieces together yet. How do I check that, and how do I change it - just move the service file? At what point are these service files created? By default the service runs as root, I changed that, but I did not change any service files...
    – phi
    Aug 2 '15 at 15:40










  • How did you install subsonic and how did you configure it to start automatically?
    – Gilles
    Aug 2 '15 at 18:21










  • I installed the deb-package with dpkg. The config in /etc/default/subsonic allows to specify a user to run the service. The startup file in /etc/init.d/ parses that file and starts the service with that user via start-stop-daemon.
    – phi
    Aug 3 '15 at 0:42












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm running a debian 4.8.4-1 x64 vanilla on a VirtualBox VM on a Win 7 x64 host. Purpose of the installation is to serve as a server for the subsonic music streaming service, which offers a webinterface on port 4040. The service runs as user 'subsonic', which is a standard user which can login, and has a home dir (not sure if this matters.)



When I start the VM from the windows host, the machine boots up and gives me a login prompt. At this point, I can access the apache webserver on port 80 from other machines, but I cannot access the subsonic service on port 4040. As soon as I login the subsonic user, the subsonic service is available.



Obviously, the subsonic service is only started after the user logs in, while apache starts before the login. What is the difference, and how do I set the subsonic service to start up before login? Is this even the right approach, or should I log in the user automatically instead?



I'm looking for a way that works, and preferrably is idiomatic to the linux philosophy.










share|improve this question















I'm running a debian 4.8.4-1 x64 vanilla on a VirtualBox VM on a Win 7 x64 host. Purpose of the installation is to serve as a server for the subsonic music streaming service, which offers a webinterface on port 4040. The service runs as user 'subsonic', which is a standard user which can login, and has a home dir (not sure if this matters.)



When I start the VM from the windows host, the machine boots up and gives me a login prompt. At this point, I can access the apache webserver on port 80 from other machines, but I cannot access the subsonic service on port 4040. As soon as I login the subsonic user, the subsonic service is available.



Obviously, the subsonic service is only started after the user logs in, while apache starts before the login. What is the difference, and how do I set the subsonic service to start up before login? Is this even the right approach, or should I log in the user automatically instead?



I'm looking for a way that works, and preferrably is idiomatic to the linux philosophy.







debian systemd services






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 26 mins ago









Rui F Ribeiro

37.3k1374118




37.3k1374118










asked Aug 2 '15 at 15:00









phi

1011




1011











  • Where is the service file that starts this service located? If it's in any user directory mentioned in systemd.unit(5), then the service will start after the user logs in.
    – saiarcot895
    Aug 2 '15 at 15:19










  • Thank you! I tried googling but I can't put the pieces together yet. How do I check that, and how do I change it - just move the service file? At what point are these service files created? By default the service runs as root, I changed that, but I did not change any service files...
    – phi
    Aug 2 '15 at 15:40










  • How did you install subsonic and how did you configure it to start automatically?
    – Gilles
    Aug 2 '15 at 18:21










  • I installed the deb-package with dpkg. The config in /etc/default/subsonic allows to specify a user to run the service. The startup file in /etc/init.d/ parses that file and starts the service with that user via start-stop-daemon.
    – phi
    Aug 3 '15 at 0:42
















  • Where is the service file that starts this service located? If it's in any user directory mentioned in systemd.unit(5), then the service will start after the user logs in.
    – saiarcot895
    Aug 2 '15 at 15:19










  • Thank you! I tried googling but I can't put the pieces together yet. How do I check that, and how do I change it - just move the service file? At what point are these service files created? By default the service runs as root, I changed that, but I did not change any service files...
    – phi
    Aug 2 '15 at 15:40










  • How did you install subsonic and how did you configure it to start automatically?
    – Gilles
    Aug 2 '15 at 18:21










  • I installed the deb-package with dpkg. The config in /etc/default/subsonic allows to specify a user to run the service. The startup file in /etc/init.d/ parses that file and starts the service with that user via start-stop-daemon.
    – phi
    Aug 3 '15 at 0:42















Where is the service file that starts this service located? If it's in any user directory mentioned in systemd.unit(5), then the service will start after the user logs in.
– saiarcot895
Aug 2 '15 at 15:19




Where is the service file that starts this service located? If it's in any user directory mentioned in systemd.unit(5), then the service will start after the user logs in.
– saiarcot895
Aug 2 '15 at 15:19












Thank you! I tried googling but I can't put the pieces together yet. How do I check that, and how do I change it - just move the service file? At what point are these service files created? By default the service runs as root, I changed that, but I did not change any service files...
– phi
Aug 2 '15 at 15:40




Thank you! I tried googling but I can't put the pieces together yet. How do I check that, and how do I change it - just move the service file? At what point are these service files created? By default the service runs as root, I changed that, but I did not change any service files...
– phi
Aug 2 '15 at 15:40












How did you install subsonic and how did you configure it to start automatically?
– Gilles
Aug 2 '15 at 18:21




How did you install subsonic and how did you configure it to start automatically?
– Gilles
Aug 2 '15 at 18:21












I installed the deb-package with dpkg. The config in /etc/default/subsonic allows to specify a user to run the service. The startup file in /etc/init.d/ parses that file and starts the service with that user via start-stop-daemon.
– phi
Aug 3 '15 at 0:42




I installed the deb-package with dpkg. The config in /etc/default/subsonic allows to specify a user to run the service. The startup file in /etc/init.d/ parses that file and starts the service with that user via start-stop-daemon.
– phi
Aug 3 '15 at 0:42










1 Answer
1






active

oldest

votes

















up vote
2
down vote













Assuming the service's name is subsonic, If you run systemctl status subsonic.service and there are no errors, then the subsonic service is being run as a system service, in which case this answer won't help much.



However, if you get an error there, but instead run systemctl --user status subsonic.service and have no errors, then that means that the service is being run under the user's instance of systemd, and the first line of the output indicates where the service file is being stored. This means that, for the service to start, the user would first have to log in.



If you want to make the service run for all users, regardless of whether the actual user is logged in or not, then move the service file to /etc/systemd/system (see man systemd.unit for the list of system paths). Additionally, if you want to have the service run under a particular user (and not under root), you'll want to add User=subsonic to the [Service] section of the file (see man systemd.service).



After moving this file, running systemctl status subsonic.service should result in some output (probably that the service is inactive, but loaded), and running systemctl --user status subsonic.service should result in an error.






share|improve this answer




















  • Thanks for the great answer! It looks like the subsonic service runs as a system service. systemctl status tells me that ExecPath=/etc/init.d/subsonic, so could this have something to do with the recent switch of the init systems? In comparison, apache2 lies in /etc/init.d/ as well, and apache becomes accessible without login. So I expect there will be another file that tells systemd when to start what. Could you point me to that please? Thanks!
    – phi
    Aug 3 '15 at 0:04










  • So the startup script is an init script. systemd automatically makes a conversion of that script to a systemd service file. To see this conversion, run systemctl cat subsonic.
    – saiarcot895
    Aug 3 '15 at 4:52










  • Great, I think I'm closing in on the issue. Comparing the service output (via cat) tells me that apache2 has SysVStartPriority=2, while subsonic has SysVStartPriority=3. I checked the init scripts of both, and can't find any parameter that might result in this difference. Do you know where to find this? Thank you, and sorry for these noob questions. I've never bothered to work with the services on a linux machine before.
    – phi
    Aug 3 '15 at 15:12










  • I actually haven't seen that property until now, and based on this, that property is now ignored. If I had to take a guess, though, it's the number that's in the name of the init script file located in /etc/rc3.d/.
    – saiarcot895
    Aug 3 '15 at 15:24











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f219763%2fstart-service-before-user-logs-in%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













Assuming the service's name is subsonic, If you run systemctl status subsonic.service and there are no errors, then the subsonic service is being run as a system service, in which case this answer won't help much.



However, if you get an error there, but instead run systemctl --user status subsonic.service and have no errors, then that means that the service is being run under the user's instance of systemd, and the first line of the output indicates where the service file is being stored. This means that, for the service to start, the user would first have to log in.



If you want to make the service run for all users, regardless of whether the actual user is logged in or not, then move the service file to /etc/systemd/system (see man systemd.unit for the list of system paths). Additionally, if you want to have the service run under a particular user (and not under root), you'll want to add User=subsonic to the [Service] section of the file (see man systemd.service).



After moving this file, running systemctl status subsonic.service should result in some output (probably that the service is inactive, but loaded), and running systemctl --user status subsonic.service should result in an error.






share|improve this answer




















  • Thanks for the great answer! It looks like the subsonic service runs as a system service. systemctl status tells me that ExecPath=/etc/init.d/subsonic, so could this have something to do with the recent switch of the init systems? In comparison, apache2 lies in /etc/init.d/ as well, and apache becomes accessible without login. So I expect there will be another file that tells systemd when to start what. Could you point me to that please? Thanks!
    – phi
    Aug 3 '15 at 0:04










  • So the startup script is an init script. systemd automatically makes a conversion of that script to a systemd service file. To see this conversion, run systemctl cat subsonic.
    – saiarcot895
    Aug 3 '15 at 4:52










  • Great, I think I'm closing in on the issue. Comparing the service output (via cat) tells me that apache2 has SysVStartPriority=2, while subsonic has SysVStartPriority=3. I checked the init scripts of both, and can't find any parameter that might result in this difference. Do you know where to find this? Thank you, and sorry for these noob questions. I've never bothered to work with the services on a linux machine before.
    – phi
    Aug 3 '15 at 15:12










  • I actually haven't seen that property until now, and based on this, that property is now ignored. If I had to take a guess, though, it's the number that's in the name of the init script file located in /etc/rc3.d/.
    – saiarcot895
    Aug 3 '15 at 15:24















up vote
2
down vote













Assuming the service's name is subsonic, If you run systemctl status subsonic.service and there are no errors, then the subsonic service is being run as a system service, in which case this answer won't help much.



However, if you get an error there, but instead run systemctl --user status subsonic.service and have no errors, then that means that the service is being run under the user's instance of systemd, and the first line of the output indicates where the service file is being stored. This means that, for the service to start, the user would first have to log in.



If you want to make the service run for all users, regardless of whether the actual user is logged in or not, then move the service file to /etc/systemd/system (see man systemd.unit for the list of system paths). Additionally, if you want to have the service run under a particular user (and not under root), you'll want to add User=subsonic to the [Service] section of the file (see man systemd.service).



After moving this file, running systemctl status subsonic.service should result in some output (probably that the service is inactive, but loaded), and running systemctl --user status subsonic.service should result in an error.






share|improve this answer




















  • Thanks for the great answer! It looks like the subsonic service runs as a system service. systemctl status tells me that ExecPath=/etc/init.d/subsonic, so could this have something to do with the recent switch of the init systems? In comparison, apache2 lies in /etc/init.d/ as well, and apache becomes accessible without login. So I expect there will be another file that tells systemd when to start what. Could you point me to that please? Thanks!
    – phi
    Aug 3 '15 at 0:04










  • So the startup script is an init script. systemd automatically makes a conversion of that script to a systemd service file. To see this conversion, run systemctl cat subsonic.
    – saiarcot895
    Aug 3 '15 at 4:52










  • Great, I think I'm closing in on the issue. Comparing the service output (via cat) tells me that apache2 has SysVStartPriority=2, while subsonic has SysVStartPriority=3. I checked the init scripts of both, and can't find any parameter that might result in this difference. Do you know where to find this? Thank you, and sorry for these noob questions. I've never bothered to work with the services on a linux machine before.
    – phi
    Aug 3 '15 at 15:12










  • I actually haven't seen that property until now, and based on this, that property is now ignored. If I had to take a guess, though, it's the number that's in the name of the init script file located in /etc/rc3.d/.
    – saiarcot895
    Aug 3 '15 at 15:24













up vote
2
down vote










up vote
2
down vote









Assuming the service's name is subsonic, If you run systemctl status subsonic.service and there are no errors, then the subsonic service is being run as a system service, in which case this answer won't help much.



However, if you get an error there, but instead run systemctl --user status subsonic.service and have no errors, then that means that the service is being run under the user's instance of systemd, and the first line of the output indicates where the service file is being stored. This means that, for the service to start, the user would first have to log in.



If you want to make the service run for all users, regardless of whether the actual user is logged in or not, then move the service file to /etc/systemd/system (see man systemd.unit for the list of system paths). Additionally, if you want to have the service run under a particular user (and not under root), you'll want to add User=subsonic to the [Service] section of the file (see man systemd.service).



After moving this file, running systemctl status subsonic.service should result in some output (probably that the service is inactive, but loaded), and running systemctl --user status subsonic.service should result in an error.






share|improve this answer












Assuming the service's name is subsonic, If you run systemctl status subsonic.service and there are no errors, then the subsonic service is being run as a system service, in which case this answer won't help much.



However, if you get an error there, but instead run systemctl --user status subsonic.service and have no errors, then that means that the service is being run under the user's instance of systemd, and the first line of the output indicates where the service file is being stored. This means that, for the service to start, the user would first have to log in.



If you want to make the service run for all users, regardless of whether the actual user is logged in or not, then move the service file to /etc/systemd/system (see man systemd.unit for the list of system paths). Additionally, if you want to have the service run under a particular user (and not under root), you'll want to add User=subsonic to the [Service] section of the file (see man systemd.service).



After moving this file, running systemctl status subsonic.service should result in some output (probably that the service is inactive, but loaded), and running systemctl --user status subsonic.service should result in an error.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 2 '15 at 16:26









saiarcot895

1,077611




1,077611











  • Thanks for the great answer! It looks like the subsonic service runs as a system service. systemctl status tells me that ExecPath=/etc/init.d/subsonic, so could this have something to do with the recent switch of the init systems? In comparison, apache2 lies in /etc/init.d/ as well, and apache becomes accessible without login. So I expect there will be another file that tells systemd when to start what. Could you point me to that please? Thanks!
    – phi
    Aug 3 '15 at 0:04










  • So the startup script is an init script. systemd automatically makes a conversion of that script to a systemd service file. To see this conversion, run systemctl cat subsonic.
    – saiarcot895
    Aug 3 '15 at 4:52










  • Great, I think I'm closing in on the issue. Comparing the service output (via cat) tells me that apache2 has SysVStartPriority=2, while subsonic has SysVStartPriority=3. I checked the init scripts of both, and can't find any parameter that might result in this difference. Do you know where to find this? Thank you, and sorry for these noob questions. I've never bothered to work with the services on a linux machine before.
    – phi
    Aug 3 '15 at 15:12










  • I actually haven't seen that property until now, and based on this, that property is now ignored. If I had to take a guess, though, it's the number that's in the name of the init script file located in /etc/rc3.d/.
    – saiarcot895
    Aug 3 '15 at 15:24

















  • Thanks for the great answer! It looks like the subsonic service runs as a system service. systemctl status tells me that ExecPath=/etc/init.d/subsonic, so could this have something to do with the recent switch of the init systems? In comparison, apache2 lies in /etc/init.d/ as well, and apache becomes accessible without login. So I expect there will be another file that tells systemd when to start what. Could you point me to that please? Thanks!
    – phi
    Aug 3 '15 at 0:04










  • So the startup script is an init script. systemd automatically makes a conversion of that script to a systemd service file. To see this conversion, run systemctl cat subsonic.
    – saiarcot895
    Aug 3 '15 at 4:52










  • Great, I think I'm closing in on the issue. Comparing the service output (via cat) tells me that apache2 has SysVStartPriority=2, while subsonic has SysVStartPriority=3. I checked the init scripts of both, and can't find any parameter that might result in this difference. Do you know where to find this? Thank you, and sorry for these noob questions. I've never bothered to work with the services on a linux machine before.
    – phi
    Aug 3 '15 at 15:12










  • I actually haven't seen that property until now, and based on this, that property is now ignored. If I had to take a guess, though, it's the number that's in the name of the init script file located in /etc/rc3.d/.
    – saiarcot895
    Aug 3 '15 at 15:24
















Thanks for the great answer! It looks like the subsonic service runs as a system service. systemctl status tells me that ExecPath=/etc/init.d/subsonic, so could this have something to do with the recent switch of the init systems? In comparison, apache2 lies in /etc/init.d/ as well, and apache becomes accessible without login. So I expect there will be another file that tells systemd when to start what. Could you point me to that please? Thanks!
– phi
Aug 3 '15 at 0:04




Thanks for the great answer! It looks like the subsonic service runs as a system service. systemctl status tells me that ExecPath=/etc/init.d/subsonic, so could this have something to do with the recent switch of the init systems? In comparison, apache2 lies in /etc/init.d/ as well, and apache becomes accessible without login. So I expect there will be another file that tells systemd when to start what. Could you point me to that please? Thanks!
– phi
Aug 3 '15 at 0:04












So the startup script is an init script. systemd automatically makes a conversion of that script to a systemd service file. To see this conversion, run systemctl cat subsonic.
– saiarcot895
Aug 3 '15 at 4:52




So the startup script is an init script. systemd automatically makes a conversion of that script to a systemd service file. To see this conversion, run systemctl cat subsonic.
– saiarcot895
Aug 3 '15 at 4:52












Great, I think I'm closing in on the issue. Comparing the service output (via cat) tells me that apache2 has SysVStartPriority=2, while subsonic has SysVStartPriority=3. I checked the init scripts of both, and can't find any parameter that might result in this difference. Do you know where to find this? Thank you, and sorry for these noob questions. I've never bothered to work with the services on a linux machine before.
– phi
Aug 3 '15 at 15:12




Great, I think I'm closing in on the issue. Comparing the service output (via cat) tells me that apache2 has SysVStartPriority=2, while subsonic has SysVStartPriority=3. I checked the init scripts of both, and can't find any parameter that might result in this difference. Do you know where to find this? Thank you, and sorry for these noob questions. I've never bothered to work with the services on a linux machine before.
– phi
Aug 3 '15 at 15:12












I actually haven't seen that property until now, and based on this, that property is now ignored. If I had to take a guess, though, it's the number that's in the name of the init script file located in /etc/rc3.d/.
– saiarcot895
Aug 3 '15 at 15:24





I actually haven't seen that property until now, and based on this, that property is now ignored. If I had to take a guess, though, it's the number that's in the name of the init script file located in /etc/rc3.d/.
– saiarcot895
Aug 3 '15 at 15:24


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f219763%2fstart-service-before-user-logs-in%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay