Quantcast
Channel: Installing and upgrading help
Viewing all 47361 articles
Browse latest View live

Re: Cron job setup not working

$
0
0
by Ken Task.  

This:

sudo crontab -u www-data -e
Added the following line to the crontab file:

*/1 * * * * /usr/bin/php /var/www/mywebsite/moodle/admin/cli/cron.php > /var/log/moodle-cron.log

Saved and exited the text editor.

Sets up the cron job.

To check it from command line ... I'll break apart the whole command and provide comments in ()

/usr/bin/php (has to find php-cli)

/var/www/mywebsite/moodle/admin/cli/cron.php

(is the full path to the cron.php script to run)

> /var/log/moodle-cron.log

Is the redirect of the output the cron.php file to a log file which has to exist.

To execute the above ... type the whole thing:

/usr/bin/php /var/www/mywebsite/moodle/admin/cli/cron.php > /var/log/moodle-cron.log

Since you are redirecting to a log file, the above will NOT ... repeat NOT ... display anything.   There will be a pause ... indicating the script is running, and then one is presented with a blank command prompt again.

TO SEE IF IT LOGGED DO THIS:

cat /var/log/moodle-cron.log

Now a test ... this is a real example:

On a server I have that has 3 instances of moodle, the cron jobs for each of them redirects to a log file for the site name:

in /var/log/ I have:
m44sb-cron.log - site is https://mysite/m44sb/
mdlandcli-cron.log - site is https://mysite/mdlandcli/
mdlsamples-cron.log - site is https://mysite/mdlsamples/

To watch just the m44sb site cron log:

tail -f /var/log/m44sb-cron.log

The command above will 'watch' that log file and when it changes, I'll see
the changes take place.

I know the cron job is running because the log file changes.
If I wait there still in tail -f /var/log/m44sb-cron.log
I can see it execute each time it executes.

To get out of tail, [CTRL][C]

To test without logging:

/usr/bin/php /var/www/html/m44sb/admin/cli/cron.php [ENTER]

When that finishes and I want to run it again ... UP Arrow on keyboard ...

my previous command is put on the command line for me.

PRESS ENTER and it runs again.

'SoS', Ken


Re: Cron job setup not working

$
0
0
by Ken Task.  

"does this mean they have executed this sudo chown -R www-data:www-data /var/www/mywebsite/public/admin/cli/cron.php?"

How would anyone here in this forums know if 'they' executed that or not?

It they did, it was wrong!!!!

-R is recursive .... at the level you point to then down into and include all.

IF ... am not saying do this ... IF I did:

chown -R www-data:www-data /var/www/mywebsite/public/admin/cli/

That would work ... it would change the owerships of all files in admin/cli/ to www-data as user and www-data as group ... which would be correct for a Ubuntu/Debian server.

That has NOTHING to do with execution of the cron script

So you try this on your server:

sudo /usr/bin/php /var/www/mywebsite/public/admin/cli/cron.php

sudo here assumes that will change user from how you logged in to running the script as the root user.

'SoS', Ken

Re: Getting error - Installation of new Moodle instance following the official document

$
0
0
by Binoit Xavier.  

I am in the process of creating Ubuntu Server Ubuntu 24.04 LTS

Re: Cron job setup not working

$
0
0
by Binoit Xavier.  

Just that In the doc that was shared with me by our previous team who setup this whole thing, where the CRON job is working successfully. The have mentioned the following "Cron jobs for the Moodle instances are run under the www-data user (crontab -u www-data -e)" How do you understand this, does this mean they have executed this sudo chown -R www-data:www-data /var/www/mywebsite/public/admin/cli/cron.php?

Re: Cron job setup not working

$
0
0
by Binoit Xavier.  

Thanks Ken. When I ran this as root user 'sudo /usr/bin/php /var/www/mywebsite/public/admin/cli/cron.php' it is executing....Also noticing that when I execute this server CPU usage is going to 100% and Putty session is getting disconnected. Not sure what is happening. The website is unreachable as well. Just wondering if this is because the CRON has not been run for  
 114 days that this server has been up. Just did a Google search and it lead me to this post https://moodle.org/mod/forum/discuss.php?d=206175 the post does not seem to have a solution.  Also noticing that it hits 100% when it comes to this step c
 


</pre>
Backtrace:
* line 796 of /mod/assign/feedback/editpdf/classes/pdf.php: call to assignfeedback_editpdf\pdf->get_image()
* line 555 of /mod/assign/feedback/editpdf/classes/pdf.php: call to assignfeedback_editpdf\pdf::get_error_image()
* line 441 of /mod/assign/feedback/editpdf/classes/document_services.php: call to assignfeedback_editpdf\pdf->get_images()
* line 591 of /mod/assign/feedback/editpdf/classes/document_services.php: call to assignfeedback_editpdf\document_services::generate_page_images_for_attempt()
* line 104 of /mod/assign/feedback/editpdf/classes/task/convert_submission.php: call to assignfeedback_editpdf\document_services::get_page_images_for_attempt()
* line 359 of /lib/cronlib.php: call to assignfeedback_editpdf\task\convert_submission->execute()
* line 198 of /lib/cronlib.php: call to cron_run_inner_adhoc_task()
* line 76 of /lib/cronlib.php: call to cron_run_adhoc_tasks()
* line 178 of /admin/cli/cron.php: call to cron_run()
 
 

Re: Cron job setup not working

$
0
0
by Ken Task.  

That's a 'task' that is part of the cron job - prepares docs submitted as assignments for online grading.

From command line and in moodle code, issue:

find ./ -name schedule_task.php

That shows a path to that file ... then cd /that/path/

and after you are in that path, issue:

sudo -u apache php schedule_task.php --execute="\assignfeedback_editpdf\task\convert_submissions"

Let it run.

You have to do that more than once to catch up.

While we are at this, don't think you've ever given us specs of your server, so issue these and share back the info:

uname -an

free -h

df -h

'SoS', Ken

Re: Cron job setup not working

$
0
0
by Binoit Xavier.  

Thanks Ken, when ran it the second or third time, the memory does not seem to max out. When I ran it the fourth time (approx) it took only 1.846983 seconds (data that is displayed on the screen). Looks like the issue is fixed regarding the memory maxing out, the (CRON task not running every minute is still there). I have a similar server where the CRON run every minute without any hassles. Here are specs of the virtual server

vCPUs
2
RAM
4GB
Networking
400Mb
SSD
120GB

Re: Cron job setup not working

$
0
0
by Ken Task.  

4G of RAM not enough ... get at least 8G of RAM.

Server under-powered for what it's trying to do! 

Assignment prep has a task:

cd code/admin/cli/
sudo -u www-data php ./scheduled_task.php -- execute="\mod_assign\task\cron_task"

Also cron jobs are run by a daemon ... crond.

Is crond running?

ps aux |grep crond

'SoS', Ken


Re: Getting error - Installation of new Moodle instance following the official document

$
0
0
by Howard Miller.  

I'm a huge fan of Docker for running test/dev instances of Moodle. It completely isolates PHP, the web server, the database, the cache and so on from the OS. The flexibility is great. BUT... it's something else to learn and it's not at all trivial.

It would have been wrong of me not to mention it, though. Like Ken always promotes Git - and you can get into a proper mess with that, too smile

Is there a way to run cron without using the command line?

$
0
0
by Mike Smith.  

Dear Moodle Experts,

Is there a way to run cron automatically without using the command line? I need to run cron every 1 minute on both of my live and local instances.

Thanks!

Mike

Re: Is there a way to run cron without using the command line?

Re: Is there a way to run cron without using the command line?

$
0
0
by Ken Task.  

In addition to Mr. V's link, some questions ... if you would care to answer ...

your 'live' system is of what 'flavor'?   Linux/Unix/other

is your 'live' system remotely hosted with a provider?   Provider name?

your 'local' system is of what 'flavor'?  Linux/Unix/other

A technical reference for you if Linux:

Linux Manaual on cron
https://www.man7.org/linux/man-pages/man8/cron.8.html

Comment: without testing running cron job from command line and if using the redirect at the end of the documented/suggested cron job command, one is 'blind' - no emails, no logs, etc.   One is only informed by moodle that cron hasn't run in x minutes/hours/days.

For a moodle, that's very bad news as the cron.php script in moodle does many backended task related to moodle DB tables and files in moodledata.

'SoS', Ken

Re: Is there a way to run cron without using the command line?

$
0
0
by Visvanath Ratnaweera.  

When one thinks of it, there must be a "command" somewhere to kick something which ultimately causes the cron.php of Moodle to run every minute. The question is how _you_ want to command that command: Talking to the OS "directly" through the Unix shell or an intermediary like a (web-based) panel.

Or, the philosophical question, how far can you walk if you suffer CLAS (Command Line Avoidance Syndrome)?
smile

Re: Is there a way to run cron without using the command line?

Re: Getting error - Installation of new Moodle instance following the official document


Re: Is there a way to run cron without using the command line?

$
0
0
by Mike Smith.  

Dear Visvanath,

Thank you for your reply. I did it before, but the cron only runs once when I input the URL with the password. I need to run the cron every 1 minute without inputting the URL every 1 minute.

How do I do that?

Mike

Re: Getting error - Installation of new Moodle instance following the official document

$
0
0
by Binoit Xavier.  

Hello Ken, just an update, I setup Ubuntu 20.04, almost completed  instance running Moodle 4.1, reached the install.php page with all the necessary user values. Getting the following message 
 

Error

Site is being upgraded, please retry later.

Re: Is there a way to run cron without using the command line?

Re: Getting error - Installation of new Moodle instance following the official document

Re: Cron job setup not working

$
0
0
by Binoit Xavier.  

This is issue fixed. Not sure what fixed it, it is working now. I edited the

crontab -u www-data -e to this
* * * * * /usr/bin/php /var/www/mywebsite/public/admin/cli/cron.php >/dev/null

First time I removed one Asterisk then ran it showed error that the data 'errors in crontab file, can't install' added the Asterisk and the ran it. Also changed /var/log/moodle-cron.log to >/dev/null. Now it is showing that it is running. How to close the request?
Viewing all 47361 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>