0

I tried simply editing the autostart file to run a Python script on boot, but it runs with errors, I assume becasue the desktop hasn't completed. Can someone tell me how I would launch a script with a delay?

3

1 Answer 1

1

you should do approximately this:

  1. crontab -e, add a line

    @reboot /home/pi/bash_script

  2. inside the bash script write the following

    #!/bin/bash

    /bin/sleep 100 && /usr/bin/python /home/pi/blah.py

where blah.py is your script you want to run with a delay.

3
  • don't I need to do a chmod on the script as well to make it executable?
    – Bachalo
    Commented Jul 24, 2014 at 14:28
  • ok, I have another issue with tKinter, if I simply run my script from LXTerminal it works, but if called via a cron job get _tkinter.TclError: no display name and no $DISPLAY environment variable
    – Bachalo
    Commented Jul 24, 2014 at 14:41
  • well, set the environment variable DISPLAY and it will run perfectly
    – lenik
    Commented Jul 24, 2014 at 16:23

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.