LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-07-2013, 02:13 PM   #1
scarr999
LQ Newbie
 
Registered: Jul 2013
Posts: 4

Rep: Reputation: Disabled
Boot script


OK I'm new to Linux but know my way around a PC and various languages, however, I cannot figure out how to run something at boot (before user login)

I have tried a few things but nothing quite works so I thought i would ask here

Hardware beagle Bone Black with Debian wheezy

Thanks

P.S. Ideally I would like to run a python script

Steve
 
Old 07-07-2013, 05:07 PM   #2
yooy
Senior Member
 
Registered: Dec 2009
Posts: 1,387

Rep: Reputation: 174Reputation: 174
There are several boot levels depending on when you want your script to start.

this may help you a bit, as you might forget googling before asking..
http://www.cyberciti.biz/tips/linux-...-boots-up.html
 
Old 07-07-2013, 05:24 PM   #3
scarr999
LQ Newbie
 
Registered: Jul 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks yooy,

I did Google first, but Google can be confusing when you are not sure about the subject.

Steve
 
Old 07-07-2013, 05:49 PM   #4
scarr999
LQ Newbie
 
Registered: Jul 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
OK, I made a script in /etc/init.d/ called mystartup.sh (see below)
then "sudo chmod +x mystartup.sh" (whilst in /etc/init.d/ directory)
ran "sudo upate-rc.d mystartup.sh defaults 100"
Rebooted and nothing :-(

### BEGIN INIT INFO
# Provides: mystartup
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: No comment yet
# Description: No comment yet
### END INIT INFO

#!/bin/bash
echo "something"
 
Old 07-07-2013, 08:10 PM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

as far as I can see, what you described should work. Can you confirm that there really is a sybolic link to your script in /etc/rc2.d/?
Eg
Code:
ls -l /etc/rc2.d/*mystartup.sh
I'm assuming you didn't change the default run level. Also, if all your script does is echo a single string then you might miss seeing it during the boot. Pheraps you could make it do something else that is easier for you too see. Eg
Code:
date  > /tmp/mystartup.txt
This just creates a text file containing the date and time it was run. Then after the machine has booted you can look for the existence of the file /tmp/mystartup.txt

Evo2.
 
Old 07-07-2013, 09:06 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Only thing I see wrong is that the #!/bin/bash line must be first...
 
Old 07-08-2013, 03:14 PM   #7
scarr999
LQ Newbie
 
Registered: Jul 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
It Works!

Thanks guys it now works, I moved #!bin/bash line and did date to file and file was there.

Now if I change the script to run a python script will it launch the script once at boot or for each terminal session I start?

Steve

P.S. Is there anything I should understand about running python scripts from shell scripts?
 
Old 07-08-2013, 05:22 PM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
If it is in /etc/init.d and specified to be started, only once per boot. It will also be invoked at shutdown.
 
Old 07-08-2013, 07:33 PM   #9
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,314
Blog Entries: 28

Rep: Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137
Brain skip.

Last edited by frankbell; 07-08-2013 at 07:34 PM.
 
Old 07-08-2013, 08:12 PM   #10
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

Quote:
Originally Posted by scarr999 View Post
Now if I change the script to run a python script will it launch the script once at boot or for each terminal session I start?
It will run once with the argument "start" each time runlevels 2-5 are entered and each time with the argument "stop" the system exists those same runlevels. The running of the script is not related to starting terminal sessions.

Evo2.
 
  


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
boot script? tzonga1 Fedora 1 11-13-2004 04:36 PM
boot script freaker2k5 Mandriva 3 08-29-2004 02:44 PM
Boot Script justaguynsrq Linux - Newbie 5 03-18-2004 11:05 AM
Stop boot script at boot time!! kmiles2 Linux - Newbie 1 02-23-2004 10:04 PM
Boot Script jhayes Linux - Software 16 07-18-2003 09:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:21 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