I have a selenium script that I created to use Iceweasel.

It works fine if I run it manually. i.e. run the command myself.

When trying to get it to run on startup it does not seem to do a thing.

I have added the following line to /etc/xdg/lxsession/LXDE-pi/autostart and /etc/xdg/lxsession/LXDE/autostart:

@python /home/pi/kiosk.py

as well as rc.local and tried various other methods. I am starting to think maybe it is a permission thing or my command is wrong.

1 Answer 1


There are various ways of running a command at startup, but you do need to make sure of certain things first:

  • Check the permissions of your file, if you think they are correct, temporarily change them to 777 (chmod 777 /path/to/script) and try that
  • Make sure the command/script works manually, which you have done
  • Make sure that the command/script either runs in the background or exits quickly as most methods of running a command/script at startup require that the command/script exits before moving on to the next.

If none of these things help, you may want to look into crontab

You can edit crontab with:

sudo crontab -u pi -e

and add:

@reboot python /home/pi/kiosk.py

assuming your command/script exits, if your command/script is a long running one, there are many ways of putting it in the background. My personal favorite is running it in a screen so you can re-access it later. Just change that line to:

@reboot screen -d -m -S Kiosk python /home/pi/kiosk.py

Once your booted, you can check to see if your script is running by entering the command screen -ls and resume it by entering screen -r Kiosk, to leave the screen but leave it running hit Control A and Control D.


I think I see your problem now. If you are trying to run a script that uses GUI at startup, there can be issues. The GUI doesn't start for a while after the boot, and almost all methods of running commands/scripts at boot runs them almost immediately. This means you will need a delay.

EX, for crontab

@reboot sleep 60; screen -d -m -S Kiosk python /home/pi/kiosk.py

This waits 60 seconds after the boot to run the script. You may need to wait longer or shorter depending on how fast your boot is. Time your boot and change the 60 to the appropriate time in seconds.

  • Will the crontab alternative run a GUI. As the selenium script opens a web browser and navigates. Jan 19, 2016 at 5:15
  • crontab should run the command as if the user pi ran the command, but it runs it as soon as possible, so you will need to add a delay, I will update my answer Jan 19, 2016 at 5:16
  • Does not seem to be working still. The pi definately does not take 1 minute to startup so 60 seconds is plenty of time. It may be an error in my script whilst running in this manner. Is there a way to export a verbose output from my script to a file? Jan 19, 2016 at 5:40
  • Yep, @reboot ... (blah blah) ... > /home/pi/Kiosk.log Jan 19, 2016 at 5:40
  • The log file was created but is empty, I am unsure where to go next Jan 19, 2016 at 5:48

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.