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?

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.

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).

  • 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. – L. Hidalgo Mar 11 '16 at 12:30
  • See superuser.com/a/299506/389434 for such a file and its location. – Axel Beckert Mar 11 '16 at 19:57
  • 1
    to acsess /etc/rc.local run – sir_ian Mar 12 '16 at 19:46
  • 1
    sudo leafpad /etc/rc.local – sir_ian Mar 12 '16 at 19:47
  • not sure why it split that up into 2 comments. :-) – sir_ian Mar 12 '16 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.