I have a shell script that uses a mapfile command.


mapfile all_lines < "/var/www/weewx/temp.txt"


If i run the shell script from the command line as in:


it runs without error.

if however I run it from crontab I get the following error:

/home/pi/WeatherCam/overlay.sh: 10: /home/pi/WeatherCam/overlay.sh: mapfile: not found

Can anyone explain why this occurs and how to fix it? Thanks for and and all help!!!

EDIT: from another forum it was suggested I change it to a bash script (#!/bin/bash) and that solved the problem... it now runs without error from crontab. The strange thing is when I ran $ which mapfile nothing is returned? (see answer below) all quite confusing!

1 Answer 1


When run under cron, your environment is not passed in, so within your script, you often need to specify the full path to binaries. For example:


/usr/local/bin/mapfile all_lines < "/var/www/weewx/temp.txt"


You'll need to find what the real path is. which mapfile may be of help.

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.