Explanation for answer
Since the craftcms supplied CLI file aka
./craft uses the following to identify it's location:
// Set path constants
// the above finds out the file path where the ./craft file is stored in
There's no need for any
cd commands in your crontab, so all you have to do, is make sure that you either have your
./craft file marked as executable (
chmod +x path/to/craft) or explicitly call it with
Since according to your observations
/home/USERNAME/CRAFTROOT/craft backup doesn't work in cron, I'd suggest using the following instead
/usr/bin/env php /home/USERNAME/CRAFTROOT/craft backup
Potential causes of issue
Now I won't guarantee that this was the cause, but it might just be the case.
- The User running the cronjobs was different compared to the one you used in ssh => different permissions => somehow broke execution through cron.
/home/USERNAME/CRAFTROOT/craft file was not marked as executable (fix ->
chmod +x /home/USERNAME/CRAFTROOT/craft), though in that case one of your ssh commands should've also failed.
- The different environment in Bash/Shell (for example, a different
$PATH or the
.bashrc not being read) in cron compared to ssh may also have been the cause behind this issue.
Other than that I'm not sure what could've caused the issue...
Q: But just to be sure, (please add a comment as answer), you ran your ssh commands without the
# infront of them, right? Otherwise it'd make sense that your ssh commands wouldn't output any failures since your commands would simply be read as comments. [A in comments]
How to figure out what the cause was
Adjust your non-working crontabs by adding
>> /home/USERNAME/CRAFTROOT/cron.log to the back of the cronjob, this'll store the output of your command into the file located at
/home/USERNAME/CRAFTROOT/cron.log, this would help in identifying what caused your issue in the first place.