I am at wits-end and am close to giving up on this... All I want to do is run a python script at bootup with the Raspberry Pi, I will outline the few things that i've tried thus far:

  1. Running the script from /etc/Profile. I used the exact script that the guy posted in his example and absolutely nothing happened. Just booted up to the normal desktop, did not open up a terminal or anything.

  2. Running the script via CRON. Tried this as well and got the same results as number one.

What on earth are some possible things that could be wrong here? Some details I can provide are that somebody else monkeyed with the OS installed on the card before I started working with it, so is it possible that I'm being prevented from running anything at startup somehow?

I am running an "LXDE" environment, if that means anything to anyone?


I did everything in the following article and I ALMOST got it working.

LXTerminal from LXDE desktop

The terminal showed up but my script did not run. The following is my script:

@/usr/bin/python /home/pi/myscript.pi

Nothing shows up in the terminal, not even the current user name (usually pi@raspberrypi).

  • If you are going to script a secret you will not get any answers which do not repeat all the similar questions on this site,
    – Milliways
    Dec 15, 2016 at 22:32
  • @Milliways See my update, I've added the script text. It's just one line where I launch python and have it execute the myscript.py from my link posted as item #1. Please let me know anything else I can add to help make the question as clear and specific as possible!!
    – Snoop
    Dec 15, 2016 at 22:37
  • Why the leading @ character? Remove that.
    – SiKing
    Dec 15, 2016 at 22:37
  • @SiKing Thanks, I will try that! Check out the link I posted in my update, that guy uses an @ character and to be honest I just copied his code verbatim. Sorry, I am probably just another person that doesn't put any thought it and rushes through things.
    – Snoop
    Dec 15, 2016 at 22:39
  • "person that doesn't put any thought it and rushes through things" is not good! 9 times out of 10 it will not work, and the 1 time you will not understand why and will just become "magic".
    – SiKing
    Dec 15, 2016 at 22:54

3 Answers 3


You failed to understand the instructions.

I used the exact script that the guy posted in his example and absolutely nothing happened. Just booted up to the normal desktop, did not open up a terminal or anything.

In the example, the author was not using a graphical environment. His Pi was setup to only boot to a command prompt! If you read through the script, it never attempts to launch a command window, it only outputs to the current window it is run in.

Assuming you followed the rest of the instructions, once your Pi boots to the graphical interface (LXDE in your case), open a command terminal (which will execute the startup /etc/profile script), and you should see the output, as per the author's comment:

Due to the technique we’ve used the script is run whenever the Pi user logs in. This means if you create other terminal sessions (via SSH for example) the script will run each time.

  • Ok, please check out my update.
    – Snoop
    Dec 15, 2016 at 22:34
  • I am starting to understand trying it in the LXDE environment.
    – Snoop
    Dec 15, 2016 at 22:35
  • All though I have yet to get this working, I do recognize that difference between what I am doing and what the tutorial does. That tutorial was not running through a graphical environment.
    – Snoop
    Dec 15, 2016 at 22:41

First you need to understand that the solutions you have researched are not the same thing!

/etc/profile is, as it says on top

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

meaning that it is the first thing that runs when someone starts a (Bourne compatible) shell. This means

  1. It will not run on boot and will not run until someone starts a shell
  2. It will run every time someone starts a new shell

If you want your script to run once at boot, then profile is the wrong solution.

You want to research the manual page of crontab, and of crontab in section 5. crontab lets you install a rules table for the cron-deamon. In section 5 you can read about how to create such a table. Run

man crontab

and read it, and then run

man 5 crontab

and read that as well.

When done, you can execute

sudo crontab -e

to edit the superuser cron rules table of your computer. You probably want to add the line

@reboot    '/usr/bin/python /home/pi/myscript.pi'

at the bottom.


Raspbian honours /etc/rc.local, so run your script from there (but above the line with exit 0 ). Any output will go directly to stdout, so if you want to keep it, redirect it to a file.

Edit: This runs in a different (root) context, and will not work for X programs - though you can put something like #!/bin/sh export DISPLAY=:0 ; sleep 60 ; myXProgram >/dev/null 2>&1 & in a script, and call it thus: myScript.sh & from rc.local. Remember to authorize local X connections elsewhere with xhost +local.

Your Answer

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

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