I am very new in linux and I don't know where I make mistake. I am using Raspbian. When I manually start script press.sh everything works fine. But when I start this script from /etc/rc.local it not works correctly.

Content of press.sh with explanation


echo "Press key ..."                #I can't see this
if read -s -t 10 -N 1               #Not wait for 10 sec.
    bash /home/monitor.sh
    sudo bash /home/pi/video_looper.conf    #This start immediately

touch /run/shm/test             #for test - this works

Here is content of rc.local

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 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"

bash /home/press.sh

exit 0
  • 2
    /home/press.sh are you sure that path is correct? I would expect you put it in the user'ss home directory, probably /home/pi/press.sh
    – Dirk
    Apr 18, 2020 at 8:44
  • Yes, path is correct. How you can see in my explanation, touch /run/shm/test work ok and sudo bash /home/pi/video_looper.conf start immediately. So script run but not work correctly.
    – Zlatko
    Apr 18, 2020 at 11:06
  • 2
    is it just the key press? You don't have any keyboard input available when starting from rc.local. A feature that is well documented. I suggest googling a bit more.
    – Dirk
    Apr 18, 2020 at 12:11

1 Answer 1



In looking at your script, I see a potential issue in the use of sudo. You may get away with this in Raspbian, but you won't in many other distributions (distros). This is due to the fact that a sudo typically demands authentication, and if you're running this at startup, you won't see the prompt.

The meaning of your comments in the script are not clear to me; e.g. "#I can't see this" - huh???

Also - the location of your script: /home/monitor.sh?!?! I don't think you should put a script in /home! Put it in /home/pi instead.

In your rc.local file you have: bash /home/press.sh

  1. You've got a shebang in your script: #!/bin/bash that specifies bash. I don't believe you need it again in front of your script name.

  2. You've specified the location of your script in /home/press.sh Really? Is that where it is? or, is it in /home/pi/press.sh?


I don't think placing your startup script in rc.local is your best move. I'm not saying it can't be made to work, but it may be more difficult than it need be. This page from the "official" documentation says (more or less) the same thing.

rc.local usage is now being deprecated in all Linux distributions in favor of systemd - a more rational, reliable and predictable approach. If you're just starting in Linux, I don't feel you'll be handicapped if you never learn to use rc.local. Here are some good references on systemd: 1, 2, 3.

Don't be intimidated by all of this documentation - learning is a process, so proceed at your own pace. But learning comes from doing more than reading, so I'd encourage you to read a little, try a little, read a little more, etc, etc.


In the meantime, there is a third alternative to starting your script at boot time: cron. It is much easier to use than rc.local or systemd, and you should be able to get your script running with very little research. I will assume that you are running as user pi, and that you can get away with using sudo in a script without authentication. Here's the approach in a nutshell:

  1. From the command line as user pi, enter the following:
export EDITOR=/bin/nano
crontab -e 
  1. You may be prompted at this point to choose an editor. I'd recommend sticking with an editor named nano. If you don't wish to use nano, choose an editor, and designate it in the export line above.

  2. When your (pi's) crontab is opened, add the following line to the bottom of the file:

@reboot (/bin/sleep 30; /home/pi/press.sh >> /home/pi/cronjoblog 2>&1)

Let's break this down:

  • @reboot tells crond to run this job at boot time

  • /bin/sleep 30 => waits 30 seconds before launching press.sh; gives the system time to gather all resources needed (networking, etc)

  • /home/pi/press.sh => launches your script

  • >> /home/pi/cronjoblog 2>&1 redirects all output (incl stderr (aka 2)) to a file - so you can see what happened!

Try this. If it doesn't work, edit your question to include some details & we'll help you troubleshoot.


As a new Linux & RPi user, one of the first things you should practice is using the documentation. However, this is a bit of an art because:

  • documentation and software aren't always in sync,
  • because different Linux distros do things differently,
  • and because, well - some people are a bit sloppy when it comes to documentation.

But the only way to overcome this is through experience. Everyone needs help from time to time - don't hesitate to ask for it. BUT: Make an effort to help yourself FIRST.

I feel the first stop in documentation is the system manuals; e.g. man crontab (from the command line, btw) would be a reasonable first step in this case. You can even check out man man to learn about the system manuals! You may not get all of your questions answered there, but you'll be able to ask more intelligent questions!

  • Tnx @Seamus for detailed answer. I put all my files in /home/pi/. I tryed this option with cronjob but result is same - video_looper.conf start immediately. In cronjoblog I get Press key .... I tryed to put in press.sh only echo "Press key ..." but when I reboot I get only command line. There is no Press key .... Maybe is problem with configuration of this program video_looper ( github.com/adafruit/pi_video_looper ). For note, if I not put sudo bash in press.sh, video_looper won't start.
    – Zlatko
    Apr 20, 2020 at 13:43
  • @Zlatko: Here's the thing: cron jobs are not intended to be interactive. Is this "Press key" input you're missing something that can be decided beforehand? Why are you running this at boot time? If you need for the program to wait for an indeterminate period of time, you can do that, but the prompt is currently going into the log file because of the >> /home/pi/cronjoblog 2>&1 specification. Please explain what it is you want to do & we'll try to help.
    – Seamus
    Apr 21, 2020 at 0:35
  • I have this video_looper and I want possibility to setup display orientation (portrait or landscape).
    – Zlatko
    Apr 21, 2020 at 6:35
  • @Zlatko: Let me see if I understand this: You've got your script started - correct? And this "Press key..." business is to set portrait vs landscape orientation after the video looper starts playing? What is it that prevents you from deciding on portrait vs landscape BEFORE you boot? Sorry - I'm not a mind-reader. If you want help, you need to describe what it is you're trying to do.
    – Seamus
    Apr 21, 2020 at 16:44
  • @Zlatko: I still don't understand your use case, but I had a thought that might help: You may want to look into using an expect script for your application. Here's a reasonable example, and you can find lots more for the price of an Internet search :)
    – Seamus
    Apr 22, 2020 at 12:25

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.