Cron-job issue: "FATAL: Must be run from ROOT directory of Grav!"

I set up a cron-job to make backups from a shell script but I get the message “FATAL: Must be run from ROOT directory of Grav!”. Any ideas how to fix this?

The shell script navigates to the Grav root folder and then executes “bin/grav backup” (no quotes). I saved the script outside the /public_html folder and also in Grav’s root but no luck so far.

Well that should work. Can you paste your script that you are running via cron?

Hello Andy, the .sh is below. I added the pwd just to make sure I was in the right folder.

#!/bin/bash
cd /home/myuser/public_html/demo;
echo “pwd: ${PWD}”
/home/twintech/public_html/demo/bin/grav backup

The output I get:

pwd: /home/myuser/public_html/demo
X-Powered-By: PHP/5.5.30
Content-type: text/html

FATAL: Must be run from ROOT directory of Grav!

I also ran the script with “bin/grav backup” as the last line and got the same error.

By the way, /demo is Grav’s root folder.

If you already cd into demo, you just need to write

#!/bin/bash
cd /home/myuser/publichtml/demo;
echo “pwd: ${PWD}”
bin/grav backup

Yeah, I tried both. Check the last line of my post.

Probably wont’ make a difference, but you could try:

./bin/grav backup

It did not make a difference, same error message. :frowning:

One year later, the fix was prefixing the command with “php-cli”:

php-cli bin/grav backup

Ah that’s a very server specific solution. Your server configuration obviously has php bound to the FCGI version, and requires you to specify the CLI version with php-cli