how do I get a script to run on boot every time with Linux? (Need this for my daughters birthday gift)
Enter your programming question at the top of this page and click Get An Answer.
Tell us how quickly you want your programming question answered.
Connect with your programmer via online chat or telephone call.
how do I get a script to run on boot every time with Linux? (Need this for my daughters birthday gift)
Hello and welcome to ExpertHelp.com! My name is Charles Totherow and I'm going to do everything in my power to answer your question to your full satisfaction!
I’m available to chat now. Please let me know that you are ready by posting a response. I’ll leave my chat session open for the next 15 minutes or so and wait for your reply. If I don’t catch you this time, please respond with a few times (including your timezone) that work best for you and we can connect then.
There are many ways to do this (depending on which distribution of linux you are using there are different tools that are offered).
The easiest way is simply adding the script to /etc/init.d and then running the command
chmod +x go.py
update-rc.d go.py defaults
If you already set up the service, you may also do so via the chkconfig command (that is if the command is available).
In that case, this command should work:
chkconfig --level 35 go.py on
There are many ways to do this (depending on which distribution of linux you are using there are different tools that are offered).
The easiest way is simply adding the script to /etc/init.d and then running the command
chmod +x go.py
update-rc.d go.py defaults
If you already set up the service, you may also do so via the chkconfig command (that is if the command is available).
In that case, this command should work:
chkconfig --level 35 go.py on
Ok, im using raspian on a pi3. Sorry im really new to programming. This is the script i want to run https://github.com/arpitjindal97/raspbian-recipes/blob/master/wifi-to-eth-route.sh . I have saved it to a folder on my desktop. Should i run the script then input those commands you just sent?
Yes please run the script first
I ran the script. Also I got a permission denied when I tried to copy the txt file I have it save in, to the /etc/init.d using the GUi
One moment please
Can you try to input the commands first, then the script
chmod: cannot access 'go.py'': No such file or directory
One moment please
Please try this:
Create a file for your startup script and write your script in the file:
$ sudo nano /etc/init.d/superscript
Save and exit: Ctrl+X, Y, Enter
Make the script executable:
$ sudo chmod 755 /etc/init.d/superscript
Register script to be run at startup:
$ sudo update-rc.d superscript defaults
If you want a script to run when you boot into the LXDE environment:
Navigate to ~/.config/lxsession/LXDE-pi
Open the autostart
file in that folder:
$ sudo nano autostart
Add @midori
on a new line. If you want to run something like a python script, put something like @python mypython.py
on a new line. Running a script file would be @./superscript
, but for some reason the script runs in an infinite loop (perhaps this will stop that).
Save and exit: Ctrl+X, Y, Enter
Restart your Raspberry Pi into the LXDE environment.
I think that did it give me a couple of mins to verify
I will be here please take your time
Was I able to resolve your question today?
Are you still with me in the chat?
sorry, it did save to the /etc/init.d folder and it did make it executable. but it seems the script no longer works...
Please try this:
sudo leafpad launch.sh
sudo leafpad /home/pi/.config/lxsession/LXDE-pi/autostart
./launch.sh
still no joy, is it possible the superscript we created is causing and issue. If so how can i delete it from the init.d folder?
There are a couple ways. If you just want to do this temporarily, you can remove the execute bit from the file:
$ chmod -x /etc/init.d/varnish
Then re-add it when appropriate:
$ chmod +x /etc/init.d/varnish
I apologize I haven’t be able to offer you the most helpful support on this issue. I have requested another Expert to step in and continue assisting you on your (product issue/question). I appreciate your patience while your new Expert prepares to assist you. When your newly assigned Expert is ready, you will be notified via email and you can continue support for your issue. You may also leave this chat page open and check for your new Experts messages
thanks,
have a good night
figured it out,
"sudo nano /etc/xdg/lxsession/LXDE-pi/autostart" then in that directory type "sudo bash" followed by a space then the address of the script in this case " /home/pi/Desktop/wif-to-eth-route.sh" . Cntrl X to exit "y" to save then "enter". Reboot and it works great for me.
I am very happy to hear that. Would there be anything else I can help you with?
Negative, Cheers!
Dear Jeffery, It was a pleasure helping you with your programming issue today. Here is a summary of the resolution.
Issue identified : Csutomer needed coding for pi3 device
Solution Implemented : I left replies with code to use at the boot of linux.
Problem solved.
If issue resurfaces in next 30 days, come back to this Question page and let me know. If you are unable to find your way back to this Question page, please contact our customer support either by email (s**t@experthelp.com) OR call us at ***-***-****
Byron Narciso
Programmer
Whether you have a quick question while preparing your taxes, troubleshooting a computer problem, or need to hire an attorney, ExpertHelp is the most convenient and affordable way to connect with the right service professional to get the job done.
ExpertHelp has been in business since 2011, is an A+ Rated Better Business Bureau accredited member, and offers a 100% satisfaction guarantee on every question you ask!