Errors during weekly gravity.sh update (cron)

I've enabled mail on my pi-hole (how to: pi-hole installation on jessie-lite)

The weekly cron job reports 3 errors (see below – bold)
I’ve checked the script, the following modifications seem to fix the errors (/opt/.pihole/gravity.sh)

Line 32: whitelistScript="**/etc/.pihole/**pihole -w"
Line 317: /etc/.pihole/pihole restartdns
Line 353: /etc/.pihole/pihole status

-----Original Message-----
To: root
Subject: Cron root@raspberrypi /usr/local/bin/pihole updateGravity

:::
::: Neutrino emissions detected...
:::
::: Custom adList file detected. Reading... done!
:::
::: Getting raw.githubusercontent.com list... List updated, transport successful!
::: Getting mirror1.malwaredomains.com list... List updated, transport successful!
::: Getting sysctl.org list... No changes detected, transport skipped!
::: Getting zeustracker.abuse.ch list... List updated, transport successful!
::: Getting s3.amazonaws.com list... No changes detected, transport skipped!
::: Getting s3.amazonaws.com list... No changes detected, transport skipped!
::: Getting hosts-file.net list... List updated, transport successful!
::: Getting raw.githubusercontent.com list... List updated, transport successful!
::: Getting someonewhocares.org list... List updated, transport successful!
::: Getting www.malwaredomainlist.com list... No changes detected, transport skipped!
::: Getting winhelp2002.mvps.org list... No changes detected, transport skipped!
::: Getting www.hosts-file.net list... No changes detected, transport skipped!
::: Getting localhost list... No changes detected, transport skipped!
:::
::: Aggregating list of domains... done!
::: Formatting list of domains to remove comments.... done!
::: 640836 domains being pulled in by gravity...
::: Removing duplicate domains.... done!
::: 538707 unique domains trapped in the event horizon.
:::
::: Adding adlist sources to the whitelist... done!
/opt/pihole/gravity.sh: line 216: pihole: command not found
::: Whitelisting 13 domains... done!
::: Nothing to blacklist!
::: Formatting domains into a HOSTS file...
:::
::: Cleaning up un-needed files... done!
:::
::: Refresh lists in dnsmasq...
/opt/pihole/gravity.sh: line 317: pihole: command not found
/opt/pihole/gravity.sh: line 353: pihole: command not found

I had one other user report this. I think it is only happening when running via cron. We'll take a look.

It is because root while running the cronjob doesn't have pihole on its path, so it can't execute it.

I am 'the other user' that Jacob referred to.

Indeed, root has nothing to rely on when running cron-jobs so the PATH has to either come from the crontab-file or from the script itself.

Seems like the daily script runs fine, the weekly script fails on every run.

See Fix missing path information for cron by DL6ER · Pull Request #983 · pi-hole/pi-hole · GitHub

did you also update update.sh?
line 82: piholeVersion=$(/etc/.pihole/pihole -v -p -c)
line 83: piholeVersionLatest=$(/etc/.pihole/pihole -v -p -l)
line 85: webVersion=$(/etc/.pihole/pihole -v -a -c)
line 86: webVersionLatest=$(/etc/.pihole/pihole -v -a -l)

see also this topic (initially reported here)

@jpgpi250 I think this not necessary anymore, since the update also knows the new path