Cron jobs not working correctly anymore

Hello!
We been running two owncloud systems for for several years now and we used until this point cron jobs configured like this:
/usr/local/bin/php -f /home/owncloud/public_html/cron.php

But that doesn’t seem to work anymore and we therefore followed the updated documentation and added:
/usr/bin/php -f /home/owncloud/public_html/occ system:cron
But no success and the cron job does run.
We use c-panel to mange our VPS servers with…
We tested the variant command php -f /home/owncloud/public_html/occ system:cron to but to no avail.

We tried to use webcron too which isn’t working itseems unless you setup an external service…

Any idea on what could be wrong here? The old configuration worked prefectly for years but since it seems that owncloud has updated the ways of doing this it no longer works with that method. We are using owncloud version 10.3.2.2 community edition.

We do receive an error from the system which is:
This script can be run from the command line only

(When using/usr/bin/php -f /home/owncloud/public_html/occ system:cron”)

Thank you in advance for the assistance.
Kind regards
PowerQuest

Hey,

maybe this is a similar environmental problem like Upgrading to 10.3.1 where i had given some testing scripts in:

Some environments doesn’t seem to provide the correct “cli” PHP environment for the PHP binary which could cause this:

This script can be run from the command line only

If you just run your occ system:cron command like so on the cli, what happens? Do you get an error message?

Alternatively you can also try adjusting your cron job to write a log file:

/usr/bin/php -f /home/owncloud/public_html/occ system:cron >> /path/to/log/owncloud-cron.log 2>&1

Make sure you’re writing the logfile somewhere where your web server process user is allowed to write.

1 Like

Thanks a bunch for your kind responses @tom42 and @eneubauer

I really appreciate that. :grinning: :+1:

Well we’re using the C-panel as mentioned before to mange our servers; the simple reason for this is that we chosen to outsource the day to day management/operations of our servers to a Danish hosting company that manage that for us so we can save time on not doing that part. So therefore we do not had sudo access/direct access to the server OS.

We can of course request that they execute anything for us. (E.g. the hosting company).
It´s is therefore of course (obviously) for that reason easier/well at at least faster for us just to enter the cron commands directly in the C-panel interface than using the commands that needs root access to the command shell/CMD.

So if i get this correctly there is no way other to do this from now on than through the CMD/shell?

Thanks in advance.
Kind regards
PowerQuest

Hi @PowerQuest,

cPanel is a typical shared hosting environment which is no longer supported by ownCloud. Specifically because of the case that sometimes it is absolutely required to run occ commands. This doesn’t necessarily require root access, but they need to be executed as the same user the web server runs.

This decision was made some time ago (I don’t know exactly it was before my time) and is probably pretty controversial especially in the community, where many people want to run ownCloud on hosting environments as cheap and efficient as possible.

As far as I know there is no other way for the cron jobs to execute.

1 Like

Hey,

i think if you can find out the correct “cli” binary for your environment you can run the occ command from within a cron job as well.

1 Like

Hello,
I’m running a a cPanel server too. I struggled with my cron not working as well. I tested a bunch of different command line options and this is the one that eventually worked consistently for me in cron for user running owncloud.

*/15 * * * * /usr/local/bin/php -f /path to owncloud public root/occ system:cron

Hope that is helpful.

Also found this important too, “The crontab requires full path of the command. The path system variable is not used in crontab.”

  • Mike
2 Likes

Well I found a way to get around the problem and running webcron instead with https://cron-job.org which is a service I found and it works great. Free too which is amazing…

However one of the two instances we are running of owncloud works great calling the /cron.php, but the other one is throwing off a 302 error for some unknown reason which I cannot figure out why:

I would be very happy for any ideas on how to resolve the 302 error.

Kind regards
PowerQuest

1 Like

Well I figured out a way to get that to work too.
instead of calling https://mydomain.com/cron.php I used https://mydomain.com/index.php/cron which does the trick. Not sure why the 302 is generated when calling /cron.php directly on that instance while the other one is working perfectly though. :thinking:

Kind regards
PowerQuest

3 Likes

I have similar problem, Cron doesn’t start automatically…

How I can call cron.php like you do?

I’m very very noob in programming and coding … please to be as clear as you can…

Thanks.

H @AmphybiouS .
I ended up using this suggestion:


Its free and works! :slight_smile:

Kind regards
PowerQuest

1 Like

@mbrando you should try and use my suggetion. It does work flawlessly. :+1:
See the link I posted in above post and just follow that.

Kind regards

2 Likes

@PowerQuest I’ll try this when I update to 10.80.0

You’re welcome. Happy to help. :smirk:
Kind regards

This will take some time! SCNR :wink: