1

After a lot of trial and failure to find a solution, i came acros adding the path to a executable script to /etc/profile the only problem is that the script only boots on the ssh sessions and not directly on the pi when i plug it in.

How may i fix it?

asked Mar 10, 2016 at 23:22

3 Answers 3

3

This works on Jessie if you want to start an app or script upon logging in to the desktop:

Add these lines in your ~/.profile:

(sleep 15 && leafpad) &

I'm using 'leafpad' here as an example; insert the path to the app or script you'd like to run.

Here's what this does:

  • Sleeps 15 seconds then launches 'leafpad'
  • The "&&" means "wait until the command before this finishes".
  • The "&" means "do this in the background; continue with the rest of the script containing this line".
  • The parentheses group things so the sleep AND the launch are both done in the background.

Because of the last "&" you can actually do several of these lines:

(sleep 15 && leafpad) &
(sleep 15 && cheese) &
(sleep 15 && epiphany) &

and they will all start a few seconds after you login to the desktop.

NOTE HOWEVER this will ALSO run this app when you ssh in to the RPi; if you are trying to run a desktop app, this may or may not be what you want. I'll look for away to NOT launch if you are connecting via ssh.

answered Aug 9, 2016 at 17:57
0

You can call the script inside /etc/rc.local.

If you have Raspbian 7 Wheezy, that should work out of the box. With Raspbian 8 Jessie, you might need to enabled systemd's rc-local.service (according to this forum posting).

answered Mar 11, 2016 at 0:49
5
  • I'm running Raspbian Jessie, How may i enable ´rc-local.service´ ? Calling the script from inside ´/etc/rc.local´ without enabling ´rc-local.service´ it doesn't run the script. Thanks a lot. Commented Mar 11, 2016 at 12:30
  • See superuser.com/a/299506/389434 for such a file and its location. Commented Mar 11, 2016 at 19:57
  • 1
    to acsess /etc/rc.local run Commented Mar 12, 2016 at 19:46
  • 1
    sudo leafpad /etc/rc.local Commented Mar 12, 2016 at 19:47
  • not sure why it split that up into 2 comments. :-) Commented Mar 12, 2016 at 19:48
0

As the script that i was trying to execute at everyboot of the pi needed another programs to boot before it execution, i solved the problem by adding a sleep time. The added lines to the /etc/profiles file looks like this:

sleep 1m
/path/to/myexecutablescript
answered Mar 12, 2016 at 18:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.