How can i add a cron job run every minute to my elearning site on moodle? - moodle

I try to add a cron job on an elearning.mysite.gr(Moodle). Although my host gives this message every hour.
Oct 2 1:10:01 linux CROND[123456]: (admin) CMD (touch /tmp/test.txt > /dev/null)
On my site administration -> notifications get this message:
The admin/cli/cron.php script has not been run for 3 days 2 hours and should run every 1 min.
At moodle documentation
/path/to/moodle/admin/cli/cron.php, can i use it ? in which way ?
I tried this :
/usr/bin/php /path/to/moodle/admin/cli/cron.php
but gives me that the process completed with error at one minute
only this touch /tmp/test.txt > /dev/null
completed with success.
Moodle Documentation:
The CLI (command line interpreter) script. This will be at the path /path/to/moodle/admin/cli/cron.php
If in doubt, this is the correct script to use. This needs to be run by a 'PHP CLI' program on your computer. So the final command may look something like /usr/bin/php /path/to/moodle/admin/cli/cron.php You can (and should) try this on your command line to see if it works. WARNING: Check your command-line PHP version is compatible with your chosen version of Moodle.-How to check it?
The command-line PHP program is different to the one running your web site and is not always the same version.
I don't know what to do...I will appreciate any help!!!
I tried by my host panel interface :
Type of progress:
Command line
URL
PHP
i should choose one from 3.
Command*:
placeholder to add my command to be excecuted
Excecute:
Dropdown
1.Cron style
2.Daily at 00:00
I use command line.
touch /tmp/test.txt
When i add
cron style and 1 * * * * * , get message for syntax.
and for
daily at 00:00 success message but on my notification of my site has
The admin/cli/cron.php script has not been run for 17 days 22 hours and should run every 1 min.
That's the icon of my Plesk Login. To change the path/to/moodle/admin/cli/cron.php xould i check the file manager in order to find cron.php file ??

As you add the cron from a web interface (maybe Plesk ?) you only need this part:
/path/to/moodle/admin/cli/cron.php
replace /path/to/moodle/ with the real path on your server, usulay something like /var/www/moodle/ or /var/www/vhosts/domain.name/httpdocs/moodle
To run every 1 minute cron style is :
* * * * *
If you can choose PHP version, choose the same version as the one you are using for Moodle.

Finally, I give this touch /tmp/test.txt ->and at cron style the touch /tmp/test.txt, as you suggest to me.
Because the other commands cannot complete with success.
But in my notifications,(Site administration-Moodle) i still get the message that cron don't run.

Related

WP-CLI: STDOUT error when called in CRON (crontab)

Little help or guidance. Server is CentOS 7 - with WHM/CPanel installed.
Command:
$(which php) $(which wp) core update --require=/opt/wp-cli-pre.php --path=/home/USER/public_html/
The contents of /opt/wp-cli-pre.php
<?php
if(!defined('STDIN')) define('STDIN', fopen('php://stdin', 'r'));
if(!defined('STDOUT')) define('STDOUT', fopen('php://stdout', 'w'));
if(!defined('STDERR')) define('STDERR', fopen('php://stderr', 'w'));
Works as expected from the command line, but if from cron job, I get:
PHP Warning: Use of undefined constant STDOUT - assumed 'STDOUT' (this will throw an Error in a future version of PHP) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/utils.php on line 1057
output of "which php"
/usr/local/bin/php
output of "which wp"
/usr/local/bin/wp
I have installed the latest WP-CLI from https://wp-cli.org/
At long last, I have found the solution.
When the CRON runs a PHP script like this: */5 * * * * php /path/to/script.php
The SAPI name is: cgi-fcgi (on a WHM/CPanel install on CentOS)
It cannot find the CLI version setup by CPanel at /usr/local/bin/php as the $PATH var is just: /usr/bin:/bin
So, the solution is to not depend on the system environment to determine the PHP you want. But to set that directly.
Like this: */5 * * * * /usr/local/bin/php /path/to/script.php
It was always my assumption that if a CRON was setup in ROOT's crontab, it would inherit ROOT's environment. This apparently is not the case.
You should take a look at the following post.
https://forums.cpanel.net/threads/users-cannot-use-wp-cli-in-cron.643293/

how to schedule console app in autosys

I have a console/executable app which I need to configure in autosys which will run every week on Sunday at 12 AM.I have never used autosys. Any help or link will be helpful related with jil command.
insert_job: JOB_NAME job_type: c
box_name: BOX_NAME (if you use one)
machine: servername
owner: account /(which will run the job, must be permissioned on the machine)/
command: whateveryouwanttorun
condition: s(previousjob) /(Means run only if previousjob is in succes state)/
description: "Description Here"
date_conditions: 1 /(1 or y for yes, 0 or n for no)/
starts_time: 00:00 /("00:00" also accepted)/
days_of_week: su
alarm_if_fail: 1 (1 or y for yes, 0 or n for no)
std_out_file: >>path\filename.log
std_err_file: >>path\errorfile.log
There are lots of other options you can invoke like use of a profile or adding variables or dates to log names etc etc. For an explanation of any of these you can ask back here or check google or ca.com for the user guide for the version of AutoSys in use at your place (commonly 11.0 or 11.3.n or possibly 4.5).
Good Luck!

EclipseFP issues with Hoogle

Installed EclipseFP, looks without any observable issues. However, when I start Eclipse, I get this:
Whether I click yes or no, the same thing happens on next restart.
Also, in the Hoogle view, I see this:
even though I see the databases seemingly OK in workspace\.metadata\.plugins\net.sf.eclipsefp.haskell.browser\scion-browser-0.2-dbs:
hackage.db 123.71 MB 31.10.2014 09:42:18 Data Base File A
local.db 3.06 MB 31.10.2014 10:20:53 Data Base File A
In the scion-browser console, I have this on startup:
>> {"rebuild":true,"filepath":"C:\\eclipse\\workspace\\.metadata\\.plugins\\net.sf.eclipsefp.haskell.browser\\scion-browser-0.2-dbs\\local.db","command":"load-local-db"}
Local database loaded
"ok"
>> {"module":"","command":"get-modules","db":"_all"}
>> {"rebuild":false,"filepath":"C:\\eclipse\\workspace\\.metadata\\.plugins\\net.sf.eclipsefp.haskell.browser\\scion-browser-0.2-dbs\\hackage.db","command":"load-hackage-db"}
Hackage databas"ok"
e loaded
>> {"module":"Prelude","command":"get-declarations","db":"_all"}
>> {"path":"C:\\eclipse\\workspace\\.metadata\\.plugins\\net.sf.eclipsefp.haskell.ui\\sandbox\\.cabal-sandbox\\bin\\hoogle.exe","command":"extra-hoogle-path"}
"ok"
>> {"command":"hoogle-check"}
C:\eclipse\workspace\.metadata\.plugins\net.sf.eclipsefp.haskell.ui\sandbox\.cabal-sandbox\bin\hoogle.exe
"Error"
Looks like hoogle is not working from the command line either:
C:\>cd C:\eclipse\workspace\.metadata\.plugins\net.sf.eclipsefp.haskell.ui\sandbox\.cabal-sandbox\bin\
C:\eclipse\workspace\.metadata\.plugins\net.sf.eclipsefp.haskell.ui\sandbox\.cabal-sandbox\bin>hoogle fmap
Could not find some databases: default
Searching in:
.
C:\eclipse\workspace\.metadata\.plugins\net.sf.eclipsefp.haskell.ui\sandbox\.cabal-sandbox\x86_64-windows-ghc-7.8.3\hoogle-4.2.36\databases
There are no available databases, generate them with: hoogle data
C:\eclipse\workspace\.metadata\.plugins\net.sf.eclipsefp.haskell.ui\sandbox\.cabal-sandbox\bin>
Any ideas here? I'll add additional information as needed, just not sure what would be useful, let me know and I'll edit.
Looks like for some reason hoogle did not work from the command line either. May be related to this:
C:\eclipse\workspace\.metadata\.plugins\net.sf.eclipsefp.haskell.ui\sandbox\.cabal-sandbox\bin>hoogle data
Downloading downloads/platform.cabal
WARNING: Could not find command line program wget.
You may be able to install it from:
http://gnuwin32.sourceforge.net/packages/wget.htm
WARNING: Could not find command line program curl.
You may be able to install it from:
http://curl.haxx.se/download.html
hoogle: Error when running Shake build system:
* default.hoo
* platform.hoo
* platform.txt
* downloads/platform.cabal.cache
* downloads/platform.cabal
Could not find downloader, neither curl nor wget are on the $PATH.
I have Cygwin installed, so I fixed this by running hoogle data from withing Cygwin terminal, which had wget available in the path and that seems to have solved the issue.

Where to find logs for a cloud-init user-data script?

I'm initializing spot instances running a derivative of the standard Ubuntu 13.04 AMI by pasting a shell script into the user-data field.
This works. The script runs. But it's difficult to debug because I can't figure out where the output of the script is being logged, if anywhere.
I've looked in /var/log/cloud-init.log, which seems to contain a bunch of stuff that would be relevant to debugging cloud-init, itself, but nothing about my script. I grepped in /var/log and found nothing.
Is there something special I have to do to turn logging on?
The default location for cloud init user data is already /var/log/cloud-init-output.log, in AWS, DigitalOcean and most other cloud providers. You don't need to set up any additional logging to see the output.
You could create a cloud-config file (with "#cloud-config" at the top) for your userdata, use runcmd to call the script, and then enable output logging like this:
output: {all: '| tee -a /var/log/cloud-init-output.log'}
so I tried to replicate your problem. Usually I work in Cloud Config and therefore I just created a simple test user-data script like this:
#!/bin/sh
echo "Hello World. The time is now $(date -R)!" | tee /root/output.txt
echo "I am out of the output file...somewhere?"
yum search git # just for fun
ls
exit 0
Notice that, with CloudInit shell scripts, the user-data "will be executed at rc.local-like level during first boot. rc.local-like means 'very late in the boot sequence'"
After logging in into my instance (a Scientific Linux machine) I first went to /var/log/boot.log and there I found:
Hello World. The time is now Wed, 11 Sep 2013 10:21:37 +0200! I am
out of the file. Log file somewhere? Loaded plugins: changelog,
kernel-module, priorities, protectbase, security,
: tsflags, versionlock 126 packages excluded due to repository priority protections 9 packages excluded due to repository
protections ^Mepel/pkgtags
| 581 kB 00:00
=============================== N/S Matched: git =============================== ^[[1mGit^[[0;10mPython.noarch : Python ^[[1mGit^[[0;10m Library c^[[1mgit^[[0;10m.x86_64 : A fast web
interface for ^[[1mgit^[[0;10m
...
... (more yum search output)
...
bin etc lib lost+found mnt proc sbin srv tmp var
boot dev home lib64 media opt root selinux sys usr
(other unrelated stuff)
So, as you can see, my script ran and was rightly logged.
Also, as expected, I had my forced log 'output.txt' in /root/output.txt with the content:
Hello World. The time is now Wed, 11 Sep 2013 10:21:37 +0200!
So...I am not really sure what is happening in you script.
Make sure you're exiting the script with
exit 0 #or some other code
If it still doesn't work, you should provide more info, like your script, your boot.log, your /etc/rc.local, and your cloudinit.log.
btw: what is your cloudinit version?

run rake ts:index from within a rake task

I am running Rails 2.3.5.
In my project I have in lib/tasks the following rake task (test_task.rake):
desc 'test_synchro_task'
task :test_synchro_task => :environment do
# A bunch of things that are properly executed (basically I am inserting
# in the database)...
# ...
# and once the above is done, I want the following to be executed,
# the sphinx index to be rebuild, but it is NOT :
system("cd /sites/project/app")
system("RAILS_ENV='staging' rake ts:index")
end
I trigger the execution of the task via a crontab containing the following entry:
13 14 * * * cd /sites/project/app && /sites/ruby/bin/rake RAILS_ENV=staging test_task
which id correctly called and executed except for 2 system lines in the task.
Please note that when I place those 2 system lines in a ruby test.rb file in my project script directory, and run it manually using the ruby command:
ruby test.rb
those 2 system commands are properly executed and the index is rebuilt correctly.
In my rake task I tried replacing those 2 system lines by:
%x["cd /sites/project/app"]
%x["RAILS_ENV='staging' rake ts:index"]
or by
#cmd="cd /sites/project/app; RAILS_ENV='staging' rake ts:index"
`#{#cmd}`
but the rake ts:index is still not executed.
Any idea why?
Many thanks.
Yves
Problem resolved:
1- In the ruby script, I found that the $?.exitstatus was 127, which is "command not found".
2- This hinted me to a PATH problem occurring in the context of cron.
3- Found that post: http://dewful.com/?p=157 titled "Ruby - Cron Not Working For Ruby Script".
4- Added the PATH in the crontab and everything works fine.
Yves