1

I want to run a command in a terminal (not background) every time my pi is completely booted (once it loads the desktop). I tried to edit the rc.local and add these commands sleep 10 chromium-browser cd path ./script but nothing happens. It doesn't even open the terminal so those commands are probably run in BG. Crontab makes the command run in BG too... is there a way to emulate me clicking on the terminal icon and typing in a few commands?

Here's my rc.local file

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "piexit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

And then the commands added by me such as sleep 10 and chromium-browser. There is also exit 0 at the end

9
  • Do you really want the terminal to be interactive (i.e. as if you typed it into a new terminal), or are you just trying to debug why your script isn't working but would otherwise be happy for it to run in the background?
    – Aurora0001
    Commented Nov 3, 2017 at 15:19
  • Also, I'd conjecture that the issue is cd path, ./script. Replace those two lines with the full path of your script e.g. /home/user/script instead and test it again. Let me know if that works so I can post a full answer for you.
    – Aurora0001
    Commented Nov 3, 2017 at 15:26
  • Ok, mine is a script that gives a live output about its status, and it would be better if I could see it, so, yes I'd like my terminal to be interactive, but actually I'm trying to debug a script that isn't working (when it times out I reboot the system and that's why I need it to run at startup). I also need to open chromium at startup and, since crontab can't open GUI programs, I thought that opening a terminal and writing chromium-browser automatically at startup would be the best solution. What do you suggest? Commented Nov 3, 2017 at 15:27
  • But chromium-browser won't start anyway and it does not need the path, right? I think there's a problem with rc local how can I test it? Commented Nov 3, 2017 at 15:29
  • 1
    Ok I'll do it ASAP Commented Nov 3, 2017 at 15:33

1 Answer 1

1

Try putting them into a script, for example ~/.start.sh Add the commands. Then run chmod 755. sudo nano ~/.config/lxsession/LXDE-pi/autostart Then add @/home/pi/.start.sh. This may work, I haven’t tested it.

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.