I have the following bash script:

if test -f "$FILE"; 
    echo "$FILE exists"
    rm -r /home/pi/test/*
    unzip /home/pi/kpidry/test.zip -d /home/pi/test/
    rm -r /home/pi/kpidry/test.zip
exit 0

The script runs fine when I run it manually, and executes all the commands as expected. However, I have added a line to rc.local in order to run the script on boot. When that runs, it executes every line except the unzip line. Could this be because the unzip program is not yet running? If so, can I run it manually in rc.local?

Any help is very much appreciated!

  • 1
    Likely because it is not in the PATH. Tried to give the full path (/usr/bin/zip or whatever)?
    – xenoid
    Commented Aug 1, 2019 at 6:51
  • 3
    "Could this be because the unzip program is not yet running" - this suggests a misunderstanding. The unzip program only runs while it's doing something. (It's not started like a Windows "service" and left to sit around until needed.) Commented Aug 1, 2019 at 7:08
  • @roaima did you mean service? Commented Aug 1, 2019 at 7:57
  • @ctrl-alt-delor yes - I avoided referring to a UNIX/Linux dæmon in case that terminology was unfamiliar. Commented Aug 1, 2019 at 8:02
  • @roaima it is still a service, a daemon is a slightly different concept. Yes most services are daemons, but not always. I have a service running on by machine that is not, it is logging to stdout. Commented Aug 1, 2019 at 8:06

1 Answer 1


I think files from /usr/bin/ are not guaranteed to be available at boot-time:

/usr/bin is a standard directory on Unix-like operating systems that contains most of the executable files (i.e., ready-to-run programs) that are not needed for booting (i.e., starting) or repairing the system. (ref: http://www.linfo.org/usr_bin.html )

Try calling "/usr/bin/unzip" instead of unzip.

If the call comes late enough and /usr/bin/ is mounted by that time and it was just the PATH environment that was missing, that could work.

  • It is true, that /usr is not guaranteed to be mounted early in the boot. However if you know that it is (such as in the standard install of raspbian), then you could add it to the PATH or access it via /usr/bin/unzip. (And I think debian is planning to or has merged /usr with the main file-system. Commented Aug 1, 2019 at 8:00
  • A typical Pi installation has /usr included as part of /. Also see this and this. Commented Aug 1, 2019 at 8:03
  • If it were a matter of unzip not being available because /usr/bin wasn't available due to the PATH not being added to the environment yet then the the lines before and after it wouldn't run either because rm is also in /usr/bin. If I'm missing something here then sleep could be added to the top of the script to allow time everything to be set in the environment. Commented Aug 1, 2019 at 9:13
  • $ which rm /bin/rm
    – markgraf
    Commented Aug 1, 2019 at 9:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .