Forums | Mahara Community

Support /
Site slowdown and crons


anonymous profile picture
Account deleted
Posts: 6

05 April 2016, 20:45

Hi,

I'm new to Ubuntu & Mahara but have eventually managed to install version 15.10.1 - it's running on a virtual machine with a decent specification.

The problem I'm having is when I reboot the server Mahara runs well, however after about 30 minutes or so it takes a long time to log in (maybe 10 minutes), and trying to access certain tabs on the page causes a large delay.

I added the following line in cron.php:

*****curl //mymaharasite/lib/cron.php >> /dev/null 2>&1

That improved the login speed a little bit, but after a while the site just grinds to a halt and only a server reboot will temporarily fix it.  After adding that line the site said cron was running successfully, although weirdly I checked later in the day and now it says it's not running.

If anyone can suggest a possible reason for this, a place to find useful logs or an alternative cron command it would be much appreciated.

Thanks

 

   

Ghada El-Zoghbi's profile picture
Posts: 122

05 April 2016, 22:33

Hi Andrew,

I don't usually run cron via curl. I usually have this in /etc/cron.d/mymaharasite

* * * * * php /path/to/mahara/htdocs/lib/cron.php >> /path/to/mahara/cron.log 2>&1

Also, are you using PostGres or MySql?

Have you tried to restart the relevant db service instead of a reboot? It would be good to narrow it down (maybe it's some setting in you db).

I.e. sudo service postgresql restart

sudo service mysql restart

Or, restart apache:

sudo service apache2 restart


It would also be useful to check the apache logs.

Make sure to turn on logging in your php.in file. You can specify the file. Usually :


/var/log/apache2/errors.log

Or something like that.

Please let me know how you go.

Cheers,
Ghada

anonymous profile picture
Account deleted
Posts: 6

05 April 2016, 23:14

Thank you for the quick reply, I'm using PostGres. 

Would I create a new file in etc/cron.d, name it the same as my site and then paste in your suggested line?

For the logging, is that just adding a line into the php.ini file?  I'm not really sure what the syntax needs to be to do that.

 

Thanks

Andrew 

Ghada El-Zoghbi's profile picture
Posts: 122

06 April 2016, 0:09

Hi Andrew,

Yes, create a file with any name but usually name it something to remind you what it's for.

As for the php.ini file, add (or uncomment ):

error_log=path/to/log /file
log_errors=1
error_reporting=E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

For more details on logging :
http://php.net/manual/en/errorfunc.configuration.php

Cheers,
Ghada
anonymous profile picture
Account deleted
Posts: 6

06 April 2016, 20:52

Hi Ghada,

I created a new file in /etc/cron.d called 'mycronjob' and entered the following line:

***** php /var/www/html/lib/cron.php >> /var/log/cron.log 2>&1

When I look in the cron.log file I get the following error:

Mahara Cron(1060) Error: bad hour; while reading /etc/cron.d/mycronjob

It then says this crontab file will be ignored.

Have I made an error in the code somewhere?

Thanks in advance

Andrew

 

 

Ghada El-Zoghbi's profile picture
Posts: 122

06 April 2016, 22:44

Hi Andrew,

You'll need to put spaces between each * .

Try that and let me know how you go.

Cheers,
Ghada
anonymous profile picture
Account deleted
Posts: 6

08 April 2016, 19:48

Hi again,

The site seems a lot quicker now but when I go to the admin section it still says cron isn't running - does it take a while to register that it's running successfully?  The entry below is from the 'cron.log' file - I presume it shows that it is running?

Apr  8 07:30:01 Mahara anacron[21264]: Anacron 2.3 started on 2016-04-08
Apr  8 07:30:01 Mahara anacron[21264]: Will run job `cron.daily' in 5 min.
Apr  8 07:30:01 Mahara anacron[21264]: Jobs will be executed sequentially
Apr  8 07:35:01 Mahara anacron[21264]: Job `cron.daily' started
Apr  8 07:35:01 Mahara anacron[21308]: Updated timestamp for job `cron.daily' to 2016-04-08
Apr  8 07:39:01 Mahara CRON[21380]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Apr  8 07:39:02 Mahara CRON[21379]: (CRON) info (No MTA installed, discarding output)
Apr  8 07:59:27 Mahara cracklib: no dictionary update necessary.
Apr  8 07:59:38 Mahara anacron[21264]: Job `cron.daily' terminated
Apr  8 07:59:38 Mahara anacron[21264]: Normal exit (1 job run)
Apr  8 08:09:01 Mahara CRON[21834]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Apr  8 08:09:01 Mahara CRON[21832]: (CRON) info (No MTA installed, discarding output)
Apr  8 08:17:01 Mahara CRON[21917]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)

 

Thanks

Andrew

Ghada El-Zoghbi's profile picture
Posts: 122

09 April 2016, 12:41

Hi Andrew,

No, I don't think it's running. Those log entries are the general php clean up.

Are you getting any errors in your apache log file?

Thanks,
Ghada
anonymous profile picture
Account deleted
Posts: 6

15 April 2016, 1:02

Hi,

 

I've checked the Apache log file and there is the following error:

PHP : syntax error, unexpected '~' in /etc/php5/apache2/php.ini on line 464

 

Line 464 is where I've put the following code:

error_log=/var/log/apache2/error.log

log_errors=1

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

 

Thanks

Andrew

 

 

Ghada El-Zoghbi's profile picture
Posts: 122

15 April 2016, 11:40

Hi Andrew,

I'm a bit baffled by that error. This is pretty much what I've got in my php.ini file.

But, you will need to add that to the cli version as cron runs in cli mode.

So, please enable error reporting in your php.ini file in /etc/php5/cli/php.ini as well.

 

And, in the Mahara code base, lib/config-defaults.php has a few configurations you should also use in config.php to display more errors:

$cfg->log_dbg_targets     = LOG_TARGET_ERRORLOG;
$cfg->log_info_targets    = LOG_TARGET_ERRORLOG;
$cfg->log_warn_targets    = LOG_TARGET_ERRORLOG;
$cfg->log_environ_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;

 

You can also try putting this in your config.php file:

$cfg->error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED;

and remove it from /etc/php5/apache2/php.ini file if it's giving you trouble.

Please remember to restart apache after making changes to your php.ini file.

 

Please note that all these $cfg settings should be removed in a production environment.

 

Let me know how you go with this.

Cheers,

Ghada

 

11 results