LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-25-2020, 11:42 PM   #1
keeneadt
Member
 
Registered: Feb 2020
Distribution: Slackware
Posts: 56

Rep: Reputation: Disabled
Auto run user service on boot without login


Hi everybody. Newbie is here. I recently switched to Slackware on my Intel NUC. This little PC serves me as 24/7 uptime syncthing client and backup storage. So it's really important for me to have it constantly turned on with syncthing service running. Sometimes electricity problems appear. My UPS has only ~5 min battery charge (it's quite new). In such cases NUC turns off due to lack of power. Anyway i have a little trick how to turn it on remotely (my family), but in this case i get running NUC without syncthing service. As far as i know run syncthing as root is not a right thing. It has write permissions and things can go bad. I'm wondering is there any way to run user service that starts on boot without user login? I found some info about runuser and test it a little
Code:
/usr/sbin/runuser --user=unprivileged syncthing -no-browser -logfile /home/unprivileged/.config/syncthing/syncthing.log
I'm going to put this command to /etc/rc.d/rc.local. Still i have some doubts about if i'm doing it correctly. I know that systemd has some sort of implementations of user services that run on boot without user login. Do we have something similar in Slackware?
 
Old 02-26-2020, 03:59 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
usually you can specify a user id to be used by a service. The service itself will be started by root, but will be run as the specified user.
Unfortunately I don't know this service, so I have no idea how can it be configured.
 
1 members found this post helpful.
Old 02-26-2020, 04:10 AM   #3
bifferos
Member
 
Registered: Jul 2009
Posts: 401

Rep: Reputation: 149Reputation: 149
Google crontab, it will run your job on boot, as a specific user.
 
Old 02-26-2020, 04:28 AM   #4
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,097

Rep: Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174
syncthing as packaged on SBo already run as the user "syncthing" and uses "su - syncthing" in its rc script to start at boot

https://slackbuilds.org/repository/1...ork/syncthing/

https://slackbuilds.org/slackbuilds/...g/rc.syncthing
 
2 members found this post helpful.
Old 02-26-2020, 07:40 AM   #5
koloth
Member
 
Registered: Jun 2004
Location: Athens, Greece
Distribution: Slack@Home - RHEL@Work
Posts: 150

Rep: Reputation: 29
It's relatively straight-forward:
As your user execute:
Quote:
crontab -e
append something like:
Quote:
@reboot <your command or scrirt>
and you should be fine
 
Old 02-26-2020, 08:47 AM   #6
keeneadt
Member
 
Registered: Feb 2020
Distribution: Slackware
Posts: 56

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bifferos View Post
Google crontab, it will run your job on boot, as a specific user.
That was the first thing i tried. For some reason it didn't work. Even if i specified sleep before run syncthing like
Code:
@reboot /usr/bin/sleep 120 && /usr/bin/syncthing
syncthing didn't start after reboot. To be honest i didn't check details.
 
Old 02-26-2020, 08:54 AM   #7
keeneadt
Member
 
Registered: Feb 2020
Distribution: Slackware
Posts: 56

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ponce View Post
syncthing as packaged on SBo already run as the user "syncthing" and uses "su - syncthing" in its rc script to start at boot

https://slackbuilds.org/repository/1...ork/syncthing/

https://slackbuilds.org/slackbuilds/...g/rc.syncthing
Yeah, now i realize what mistake i made when i tried to run system wide service as root for the first time. I completely forgot about permissions. I just copied my old .config/syncthing to /var/lib/syncthing/config. Now it works after recursive changing permissions of /var/lib/syncthing/config to syncthing:syncthing and moving actual syncthing folder to accessible place. The service starts syncthing as syncthing user.

Thanks a lot everybody.
 
Old 02-26-2020, 09:00 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
that is great.
If you think your problem is solved please mark the thread solved. Also if you wish to say thanks just click on yes.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need auto run in games without an auto run, used to use AutoHotKey in Windows, trying AutoKey, but having problems eric1234 Linux - Games 15 02-01-2019 11:58 AM
Auto run and only run a program after login? narke Slackware 2 05-27-2011 12:51 PM
Auto-login (KDE) - will not auto-login without monitor attached Mithrilhall Linux - General 2 03-04-2008 10:16 AM
How to configure auto login & after login auto startup some program. hocheetiong Linux - Newbie 1 02-18-2008 12:49 AM
Auto-login Without user and password hraposo Fedora 1 07-12-2006 07:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration