We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Cron job custom setup | Forum

Topic location: Forum home » Support » General Questions
Ash
Ash Oct 27 '19
Hi

I have set cron to 5mins* How do i further customize it NOT to Run after 10pm till morning 8am ?


My reminders plugin which is based on cron job, run at night and 12am notifications to members is not good! 


Any help will be really appreciated.

Look fw

Cheers!

OW-Ghost
OW-Ghost Oct 27 '19
but you cron must run for message plugin working and i think for sign up working and many other things? and heavy load when start after stop long time.


so you want to close website in daytime or nightime?


if that is the case , sure you can do that. and it all depends what cron manager you use? are you use cpanel? or what cron manager software you use? 


if i was you i would rather customize the reminder plugin then stop cron some hours

The Forum post is edited by OW-Ghost Oct 27 '19
Marcus
Marcus Oct 27 '19
Edit pluging cron.php at the very top add some like this.

if(date("G") !=11)
{
return;
}

This will prevent below code to be run 
unless it's 11 am

From your post it appears your cron.php 
already has similar code. 
Pls post te content of your file. 
The Forum post is edited by Marcus Oct 27 '19
Ash
Ash Oct 28 '19
Hi Thanks for your reply -- Can you Please send me path there are many cron.php codes of which one you mentioning to paste?
Quote from Marcus Edit pluging cron.php at the very top add some like this.
if(date("G") !=11){return;}
This will prevent below code to be run unless it's 11 am
From your post it appears your cron.php already has similar code. Pls post te content of your file.

Ash
Ash Oct 28 '19
Yes you are right - it may be possible of some one pvt msg then notifications should go.. so you are telling me that i should add some codes in reminder cron.php right? 


Can you please further help with steps, i am using shared hosting/ linux/ cpanel 
Quote from Skadate Sweden but you cron must run for message plugin working and i think for sign up working and many other things? and heavy load when start after stop long time.


so you want to close website in daytime or nightime?


if that is the case , sure you can do that. and it all depends what cron manager you use? are you use cpanel? or what cron manager software you use? 


if i was you i would rather customize the reminder plugin then stop cron some hours



Quote from Skadate Sweden but you cron must run for message plugin working and i think for sign up working and many other things? and heavy load when start after stop long time.


so you want to close website in daytime or nightime?


if that is the case , sure you can do that. and it all depends what cron manager you use? are you use cpanel? or what cron manager software you use? 


if i was you i would rather customize the reminder plugin then stop cron some hours


Ash
Ash Oct 28 '19
This is the code of my reminder cron.php


class REMINDER_Cron extends OW_Cron {
    public function __construct() {        parent::__construct();
        $activity = (int) OW::getConfig()->getValue('reminder', 'activityCron');        $avatar = (int) OW::getConfig()->getValue('reminder', 'avatarCron');        $friendship = (int) OW::getConfig()->getValue('reminder', 'friendshipCron');
        $this->addJob('sendInactivityMails', $activity * 24 * 60);        $this->addJob('sendAvatarMails', $avatar * 24 * 60);        $this->addJob('sendFriendshipMails', $friendship * 24 * 60);    }
    public function run() {            }
    public function sendInactivityMails() {        REMINDER_BOL_Service::getInstance()->processInactiveUsers();    }
    public function sendAvatarMails() {        REMINDER_BOL_Service::getInstance()->processUsersSansAvatar();    }
    public function sendFriendshipMails() {        REMINDER_BOL_Service::getInstance()->processPendingFriendship();    }
}


---

so please guide how to stop this plugin not to run in night 10pm to morning 8am

Marcus
Marcus Oct 28 '19
if(date("G") >= '22' && date("G" ) <= '8' )
{
return;
}

Add this code after

parent::__construct() ;

Keep in mind I'm shooting in the dark here 
since am using my sell phone. 

But basically you need to either prevent pluging
from adding those 3 jobs or inside each job
function perform time check. 
The Forum post is edited by Marcus Oct 28 '19
Ash
Ash Oct 28 '19
Hi - should i try it out? or should i wait.. if some one can please further validate if you are not sure?
The Forum post is edited by Ash Oct 28 '19
Ash
Ash Oct 28 '19
Or this can also be a way out? refer screen shot below.. will this make the cron start by 8am daily for mins? 


If yes then it may fulfill the purpose of sending reminder in morning rather then running on 12am?



Marcus
Marcus Oct 28 '19
Server cron should remain same. It should fire every min. My code will not brake the pluging it will only prevent the code below from running unless the specified criteria has been meat.

Please install xsammp server on your pc along with ow and test your codes there first. 
The Forum post is edited by Marcus Oct 28 '19
Ash
Ash Oct 28 '19
Okey! Cool Thanks @Marcus
Quote from Marcus Server cron should remain same. It should fire every min. My code will not brake the pluging it will only prevent the code below from running unless the specified criteria has been meat.
Please install xsammp server on your pc along with ow and test your codes there first. 

ArtMedia
ArtMedia Nov 10 '19
on your cpanel, set cronjob writing on on minutes "*/5" and hours, 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 then cronjob will be executed every 5 minutes from 8am to 10pm
Ash
Ash Nov 10 '19

Quote from ArtMedia on your cpanel, set cronjob writing on on minutes "*/5" and hours, 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 then cronjob will be executed every 5 minutes from 8am to 10pm
Wow thanks a lot!!!