I have a bash script that sources a file, which sources another:
script.sh:
cd /script/dir
source funcs.sh
funcs.sh:
...
source mode.sh
Now this script runs OK when I run it from command line, from within /script/dir.
But when I run it from crontab, the funcs.sh file can't find mode.sh.
Probably because for some reason the cd /script/dir
doesn't get passed on to it?
Is there anything I can do from within script, or do I need to cd in the cron or something similar?
#!
-line? Depending on what shell is running the script (and how it's running it), thesource
command may or may not search the current directory for the dot-script. – Kusalananda Feb 28 '23 at 08:15