Closed Grayches closed 2 weeks ago
can you run the script without cron successfully?
#!/bin/sh
cd /home/USER/public_html
bin/plugin warm-cache warm https://example.com/sitemap.json
with: ./your-script.sh
???
??
Hi,
I move the script into the root directory yes it runs ok with ./warm-cache.sh. The docs say to put this script into the bin file.
I copied this to the root and changed the cron to point at it with home/user/public_html/warm-cache.sh and “FATAL: Must be run from ROOT directory of Grav!”
With ./warm-cache.sh in the cronjob it says file not found.
I took out the middle line from the script (cd /home/USER/public_html) and tried to run again by pointing to the script from cron and says “FATAL: Must be run from ROOT directory of Grav!”
From: Andy Miller @.> Sent: Monday, June 17, 2024 6:42 PM To: getgrav/grav-premium-issues @.> Cc: Grayches @.>; Author @.> Subject: Re: [getgrav/grav-premium-issues] [site-toolbox] Warm-cache cron issue (Issue #447)
can you run the script without cron successfully?
cd /home/USER/public_html bin/plugin warm-cache warm https://example.com/sitemap.json
with: ./your-script.sh ???
??
— Reply to this email directly, view it on GitHub https://github.com/getgrav/grav-premium-issues/issues/447#issuecomment-2173976392 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BIQBEBGJ6SX5C2EU2XTHOW3ZH4NWZAVCNFSM6AAAAABJMQ4ITWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZTHE3TMMZZGI . You are receiving this because you authored the thread.Message ID: @.***>
The script file itself can be anywhere, so a good place is in a bin/
folder in your user's root (e.g. ~/bin
same as /home/USER/bin/
). you really don't have to put it in the public_html
folder, that is for your web files. Update your cron to point to the /home/USER/bin/warm-cache.sh
file and i don't see why that would not work for you.
Did you not update the USER to your Actual user? for example, mine is /home/rhuk/...
USER is just a placeholder.
Yes I changed the name to my username. It finds the script otherwise it returns “no file or dir” but then keeps returning the from ROOT error.
The script is:
cd /home/MYUSER/public_html/
bin/plugin warm-cache warm https://MYSITE.com/sitemap.json
returned: Output from Job ID: warm-cache
Command: /home/ MYUSER /bin/warm-cache.sh
Content-type: text/html; charset=UTF-8
FATAL: Must be run from ROOT directory of Grav!
With scheduler set up as below:
From: Andy Miller @.> Sent: Monday, June 17, 2024 9:55 PM To: getgrav/grav-premium-issues @.> Cc: Grayches @.>; Author @.> Subject: Re: [getgrav/grav-premium-issues] [site-toolbox] Warm-cache cron issue (Issue #447)
The script file itself can be anywhere, so a good place is in a bin/ folder in your user's root (e.g. ~/bin same as /home/USER/bin/). you really don't have to put it in the public_html folder, that is for your web files. Update your cron to point to the /home/USER/bin/warm-cache.sh file and i don't see why that would not work for you.
Did you not update the USER to your Actual user? for example, mine is /home/rhuk/... USER is just a placeholder.
— Reply to this email directly, view it on GitHub https://github.com/getgrav/grav-premium-issues/issues/447#issuecomment-2174406086 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BIQBEBHOXNQYBWVP6UTBS23ZH5EJVAVCNFSM6AAAAABJMQ4ITWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZUGQYDMMBYGY . You are receiving this because you authored the thread.Message ID: @.***>
Could please post the screenshot via Github and not email. It gets lost and I can't see it.
Ive tried ammending the script to
bin/plugin warm-cache warm https://example.com/sitemap.json
putting it in the root folder of grav public_html then calling that from dron and still get FATAL: Must be run from ROOT directory of Grav!
Ive tried running cron from cpanel:
same output:
Content-type: text/html; charset=UTF-8 FATAL: Must be run from ROOT directory of Grav!
Ive tried again this morning by putting the warm-cahce.sh script into the root folder and pointg the cron directly to it and to output the dir to log file to prove it is running from the root of grav, it is but still displays the same error:
LICENSE.txt
assets
backup logs
bin now.json
cache README.md
CHANGELOG.md robots.txt
CODE_OF_CONDUCT.md SECURITY.md
composer.json system
composer.lock tmp
CONTRIBUTING.md user
error_log vendor warm-cache.sh
images webserver-configs
index.php
Content-type: text/html; charset=UTF-8
FATAL: Must be run from ROOT directory of Grav!
prefixing the command with "php-cli" resolved the issue:
php-cli bin/plugin warm-cache warm https://example.com/sitemap.json
I thought I had already tried this but must of had something else wrong at the time from the prior attempts.
ok, I got that wrong. That gives php-cli: command not found
I tried with php -C -f bin/plugin warm-cache warm https://example.com/sitemap.json
and got:
Usage: [slug] [command] [arguments]
Example: error log -l 1 --trace
Plugins with CLI available:
so still not running from cron but works fine from CLI
OK this time it is fixed. I had to use the below:
/opt/alt/php74/usr/bin/php bin/plugin warm-cache warm https://example.com/sitemap.json
I took this prefix from the scheduler cron for anyone else with this issue.
I have warm-cache premium plugin, I can run it fine from command line with the below commands:
cd /home/USER/public_html bin/plugin warm-cache warm https://example.com/sitemap.json or
/home/user/public_html/bin/plugin warm-cache warm https://example.com/sitemap.json
both esentially the same thing. However, when I save this as a shell script as per the docs, in root/bin:
!/bin/sh
cd /home/USER/public_html bin/plugin warm-cache warm https://example.com/sitemap.json I get the following error when run with cron:
2024-06-15T08:23:02+01:00 Content-type: text/html; charset=UTF-8 FATAL: Must be run from ROOT directory of Grav
Aside from the above Ive tried
cd … cd “/…/” .bin/plugin warm-cache warm https://example.com/sitemap.json cd /home/USER/public_html cd “/home/USER/public_html/”
I cant see what Im missing?
The alternative is “if onCacheClear Event” is enabled in the plugin settings does this still trigger from the cache-clear cron job? If so I dont need any of the above as this is set up and working.