Forums | Mahara Community
Site slowdown and crons
05 April 2016, 8:45 PM
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.
05 April 2016, 10:33 PMHi 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 :
Or something like that.
Please let me know how you go.
05 April 2016, 11:14 PM
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.
06 April 2016, 12:09 AMHi 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_reporting=E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
For more details on logging :
06 April 2016, 8:52 PM
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
06 April 2016, 10:44 PMHi Andrew,
You'll need to put spaces between each * .
Try that and let me know how you go.
08 April 2016, 7:48 PM
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: Anacron 2.3 started on 2016-04-08
Apr 8 07:30:01 Mahara anacron: Will run job `cron.daily' in 5 min.
Apr 8 07:30:01 Mahara anacron: Jobs will be executed sequentially
Apr 8 07:35:01 Mahara anacron: Job `cron.daily' started
Apr 8 07:35:01 Mahara anacron: Updated timestamp for job `cron.daily' to 2016-04-08
Apr 8 07:39:01 Mahara CRON: (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: (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: Job `cron.daily' terminated
Apr 8 07:59:38 Mahara anacron: Normal exit (1 job run)
Apr 8 08:09:01 Mahara CRON: (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: (CRON) info (No MTA installed, discarding output)
Apr 8 08:17:01 Mahara CRON: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
09 April 2016, 12:41 PMHi 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?
15 April 2016, 1:02 AM
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_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
15 April 2016, 11:40 AM
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.