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

Notices


Reply
  Search this Thread
Old 05-25-2017, 07:24 AM   #1
bobkatz
LQ Newbie
 
Registered: Jan 2010
Distribution: Whatever's in my Thecus 5500!
Posts: 22

Rep: Reputation: 1
Can't get this script to run at startup


I'm a linux desktop newbie (have some experience with linux via ssh). I've set up a desktop machine with Fedora 26 to run backuppc. Why Fedora 26? Because no extras are needed in order to install backuppc, it can be installed via dnf.

Anyway, I'm trying to get a script to run at startup. It does run if manually started. Its got 751 permissions. I know that's excessive, but I'm trying to fix the problem it doesn't run automatically at startup.

The script starts up backuppc and starts up apache:

#!/bin/bash
systemctl enable backuppc
systemctl start backuppc
apachectl start

Right now my system is littered with attempts to make this script start. I've got copies of it all over the place :-(. I've tried ~/.config/autostart methods, I've tried making /etc/rc.local but apparently systemd based linux doesn't like that method. I've tried making a service that calls the script and that hasn't helped. I've tried using a .desktop file and that hasn't helped.

However I haven't tried making a service with the commmand lines in it directly and I think it's time to ask the experts or stump the chumps! I wonder if the problem has to do with automatically running a service that runs a script with systemctl commands?

Maybe there's another way to do this? Thanks for being there!

Last edited by bobkatz; 05-25-2017 at 07:26 AM.
 
Old 05-25-2017, 08:04 AM   #2
kudsu
Member
 
Registered: Apr 2017
Location: from LA
Distribution: Slackware and anything
Posts: 50

Rep: Reputation: Disabled
Are you using GRUB? Did you google?
 
Old 05-25-2017, 11:36 AM   #3
bobkatz
LQ Newbie
 
Registered: Jan 2010
Distribution: Whatever's in my Thecus 5500!
Posts: 22

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by kudsu View Post
Are you using GRUB? Did you google?
Yes, I've been googling extensively on this topic and have spent many fruitless hours trying different scenarios for startup scripts as I mentioned.

Yes, I'm using Grub, though I don't understand the relevance of that. I understand that grub 2 is in the boot sector and refers to a config file on the main sector. But that's for the early part of the boot, the kernel. I'd like my script to run after login.
 
Old 05-25-2017, 11:45 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,783

Rep: Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936
Have you looked at the logs or status to see why backkuppc is not starting at boot up? Did you enable apache to start at boot up?

systemctl status backuppc

rc.local should work if you enable the rc-local service and change the /etc/rc.local permissions to execute.

You need root or sudo permissions to run systemctl. /etc/rc.local should run as root.
 
Old 05-25-2017, 03:18 PM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by bobkatz View Post
#!/bin/bash
systemctl enable backuppc
systemctl start backuppc
apachectl start
once you enable a systemd service, it starts automatically at boot.
so there's no need for the script!
i would replace the last line with 'systemctl enable apache2' - but again, not scripted! only once!

reboot => instant joy!
 
1 members found this post helpful.
Old 05-26-2017, 10:06 AM   #6
bobkatz
LQ Newbie
 
Registered: Jan 2010
Distribution: Whatever's in my Thecus 5500!
Posts: 22

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by ondoho View Post
once you enable a systemd service, it starts automatically at boot.
so there's no need for the script!
i would replace the last line with 'systemctl enable apache2' - but again, not scripted! only once!

reboot => instant joy!
Thanks ondoho. VERY HELPFUL! That did it. On Fedora 26 I had to do

systemctl enable http


And that was the key. Now I have to search through and delete all my useless startup scripts! This thread can be closed. Again, thanks, everyone.

Bob
 
1 members found this post helpful.
Old 05-27-2017, 01:46 AM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by bobkatz View Post
And that was the key. Now I have to search through and delete all my useless startup scripts!
Hehe, someone likes systemd

please mark your thread solved (menu at top of thread, thread tools => solved).
also clicking "Yes" on the most helpful post will be appreciated.
 
  


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 to run script at startup. pinga123 Linux - Newbie 6 02-04-2010 11:05 AM
Run Script on Startup aneesali Linux - Newbie 2 06-23-2007 01:55 PM
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
get a script to run on startup kram Debian 3 04-23-2005 02:23 PM
Run a script at startup iain.ross Linux - Newbie 8 08-27-2004 04:03 PM

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

All times are GMT -5. The time now is 01:57 AM.

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