Codoforum related discussions
external cron execution

I have trouble with mails sent by cron, as 9/10 time, mail is sent when the destination user log on smile
i set mail_notify_send to 90s, but, is there a way to run cron externally ( with a php call, by exemple or with CLI) ?

Thanks by advance...

I have trouble with mails sent by cron, as 9/10 time, mail is sent when the destination user log on :) i set mail_notify_send to 90s, but, is there a way to run cron externally ( with a php call, by exemple or with CLI) ? Thanks by advance...

please, excuse my bad english! ( i'm french, and i know, it's not a good excuse ! ;) )

I have trouble with mails sent by cron, as 9/10 time, mail is sent when the destination user log on smile

What do you mean ?

i set mail_notify_send to 90s, but, is there a way to run cron externally ( with a php call, by exemple or with CLI) ?

Yes, the below lines will run the cron for you

 $cron = new \CODOF\Cron\Cron();
 if (!$cron->run($name)) {

      echo 'Unable to run cron ' . $name . ' because another cron is already running';
 }

You can get the name of fron admin -> system/cron

So, you can just write this in an external script and execute it from your crontab

>I have trouble with mails sent by cron, as 9/10 time, mail is sent when the destination user log on smile What do you mean ? i set mail_notify_send to 90s, but, is there a way to run cron externally ( with a php call, by exemple or with CLI) ? Yes, the below lines will run the cron for you ``` $cron = new \CODOF\Cron\Cron(); if (!$cron->run($name)) { echo 'Unable to run cron ' . $name . ' because another cron is already running'; } ``` You can get the name of fron admin -> system/cron So, you can just write this in an external script and execute it from your crontab
edited Nov 21 '16 at 5:31 pm

ok, i'm not clear. I explain:
cron jobs in forum are run at specified interval. but this this interval is verified by function run in sys/CODOF/Cron.Cron.php, i'm right ?

but this function is called only when someone connected to the forum read something ( maybe a cache fault ?), not at any connection to the forum home page.

so, the idea is to have a .php called externally ( with a direct url like http://mysite.com/cron.php ) by a system cron or an external site to ensure cron jobs are run , even if there is no connection to the forum ( is it more clear ?)

ok, i'm not clear. I explain: cron jobs in forum are run at specified interval. but this this interval is verified by function run in sys/CODOF/Cron.Cron.php, i'm right ? but this function is called only when someone connected to the forum read something ( maybe a cache fault ?), not at any connection to the forum home page. so, the idea is to have a .php called externally ( with a direct url like http://mysite.com/cron.php ) by a system cron or an external site to ensure cron jobs are run , even if there is no connection to the forum ( is it more clear ?)

please, excuse my bad english! ( i'm french, and i know, it's not a good excuse ! ;) )

Yes, we can provide an external url, infact there already is one: Ajax/cron/run

But, the problem is of security. Right now, when this request is made,
you need to pass a token as well as the user should have admin role.

This is not possible when you make external requests via system cron.
We will have to implement something like Oauth2 to handle this.

Yes, we can provide an external url, infact there already is one: `Ajax/cron/run` But, the problem is of security. Right now, when this request is made, you need to pass a token as well as the user should have admin role. This is not possible when you make external requests via system cron. We will have to implement something like Oauth2 to handle this.
edited Dec 18 '16 at 11:45 am

hello @adesh1414127033 and thanks for your answer.
I'm trying to investigate the oAuth2 way, as we use google and Facebook logins smile. I'll report here my tests smile
But maybe add an oauth2 server in codoforum ? ( ouch! i did it for one of my professionnal work, not so easy!!! https://bshaffer.github.io/oauth2-server-php-docs/cookbook/)

I think it can be done with a system cron and a shell script with curl ( https://labs.hybris.com/2012/06/18/trying-out-oauth2-via-curl/)

hello @adesh1414127033 and thanks for your answer. I'm trying to investigate the oAuth2 way, as we use google and Facebook logins :). I'll report here my tests :) But maybe add an oauth2 server in codoforum ? ( ouch! i did it for one of my professionnal work, not so easy!!! https://bshaffer.github.io/oauth2-server-php-docs/cookbook/) I think it can be done with a system cron and a shell script with curl ( https://labs.hybris.com/2012/06/18/trying-out-oauth2-via-curl/)

please, excuse my bad english! ( i'm french, and i know, it's not a good excuse ! ;) )

edited Dec 22 '16 at 9:33 am

Hi

Thanks for providing those links.
They were quite useful.

I will do some research on some other options and will implement this.

Hi Thanks for providing those links. They were quite useful. I will do some research on some other options and will implement this.
256
5
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft