I am having big issues with the cron of Magento 1.9.1 hoping someone can help. I have AOE installed and see not heartbeat.
I have added my cron job
*/5 * * * * /bin/sh /var/sites/p/domain/public_html/cron.sh
But this still does not run, so I decided to try and try and run cron.php, this does nothing. This is my cron for this
*/5 * * * */usr/bin/wget -O /dev/null -o /dev/null http://www.domain.com/cron.php
Based on Magneto 1.8 cron.php I added the following to the cron.php.
$isShellDisabled = true;
Based on this still not working I tried the cron.php in the browser. I get an error in the browser that Printing is disabled by default for security reasons.
So I changed my php.ini to memory_limit = 512M just incase. This is still not working.
The error I get in my reports for this is:
a:5:{i:0;s:59:"Mage registry key "_singleton/cron/observer" already exists";i:1;s:537:"#0 /var/sites/p/domain.co.uk/public_html/app/Mage.php(223): Mage::throwException('Mage registry k...')
#1 /var/sites/p/domain.co.uk/public_html/app/Mage.php(477): Mage::register('_singleton/cron...', false)
#2 /var/sites/p/domain.co.uk/public_html/app/code/core/Mage/Core/Model/App.php(1316): Mage::getSingleton('cron/observer')
#3 /var/sites/p/domain.co.uk/public_html/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('default', Array)
#4 /var/sites/p/domain.co.uk/public_html/cron.php(74): Mage::dispatchEvent('default')
#5 {main}";s:3:"url";s:9:"/cron.php";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";}
Any help would be really great.
Note ** I have change the domain name to DOMAIN due to my site not being suitable for work.
Few simple steps to fix Magento cron issue:
Go to System > Configuration > Advanced > System > Cron (Scheduled Tasks) and set next values:
Generate Schedules Every: 15
Schedule Ahead for: 20
Missed if Not Run Within: 15
History Cleanup Every: 10
Success History Lifetime: 60
Failure History Lifetime: 600
Clear Cache in System > Cache Management
Clear 'cron_schedule' table. You can do it via phpmyadmin or execute next command in SQL console:
TRUNCATE TABLE cron_schedule;
Add next line to cron settings (use absolute paths):
*/5 * * * * /usr/bin/php /absolute/path/on/your/server/to/file/cron.php
Note: in some configurations on webserver (apache/nginx) allowed to execute php scripts. In this case add this line to webserver's user crontab. Example for apache: crontab -u apache -e
Restart cron daemon.
Check table 'cron_schedule', if it's not empty - Magento cron script start working.
Well I've had a different issue. My cron was simply not working, although cron.php was executed properly. Still no output, and no jobs done.
I've checked cron_schedule and noticed that last job there is from 19th of March this year (sic!). So i kept on looking for cause.
Finally I've noticed that that there is process running with my cronjob from 19th of March (sic!).
josh 21350 99.6 0.4 350400 133492 ? R Mar19 241812:21 /usr/bin/php /var/www/mysite/cron.php -mdefault
I've killed the job with: kill -9 21350
And voila! Suddenly newsletter is being sent!
I had no idea why, and how this happened. Now i know i should pay attention to it, so I will.
I just saw that you are using magento 1.9.1.
Run the cron using php instead : /usr/local/bin/php -f /home/cpanel_username/public_html/cron.php
This should resolve http permission problems you might be having when using 'usr/bin/wget -O /dev/null -o /dev/null'
Try that command and let me know if it works for you.
Related
I have this in my Kernal.php:
$schedule->call('removeTemporaryFiles')->everyMinute();
When I hit php artisan schedule:run it works like charm. But I also ran:
* * * * * php /var/www/html/archive/artisan schedule:run >> /dev/null 2>&1
But it is not running automatically. I have waited more than a minute but it is still not running. What am I doing wrong?
And where is the main machine cron saved? The one that runs every minute and calls artisan schedule:run?
In order for Schedules to run, you need first to add the cron job to your cron table. Run this command
sudo crontab -e
Then choose your preferred editor.
Then add the below line:
* * * * * php /var/www/html/archive/artisan schedule:run >> /dev/null 2>&1
Finally in your Kernel.php you add the schedule:
$schedule->command(<artisan command>)->everyMinute();
The documentation is perfectly detailing it.
Finding cron jobs:
Depending on how your linux system is set up, you can look in:
- /var/spool/cron/* (user crontabs)
- /etc/crontab (system-wide crontab)
also, many distros have:
- /etc/cron.d/* These configurations have the same syntax as /etc/crontab
- /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthly
These are simply directories that contain executables that are executed hourly, daily, weekly or monthly, per their directory name.
On top of that, you can have at jobs (check /var/spool/at/*), anacron (/etc/anacrontab and /var/spool/anacron/*) and probably others I'm forgetting.
References : https://unix.stackexchange.com/questions/7053/how-can-get-a-list-of-all-scheduled-cron-jobs-on-my-machine
I try to run PHP scripts on my debian server, everyday at midnight & 1 minute.
So I created the crontab file in admin, with
crontab -e
who seems to be in
/tmp/crontab.ky3Q3F/crontab
And I put the line
01 00 * * * /usr/bin/php5 /var/www/MySite/cronTB.php
Bellow the comments.
The goal is to run cronTB.php (with PHP) everyday at 0h01.
Is my syntax correct ?
Is the correct file to edit, to the correct path ?
Is the CRON daemon still runing after I run it with:
/etc/init.d/cron start
even if I close the ssh connexion ?
Thanks for help
I'm trying to set up a cronjob script on my server. I've followed this tutorial and I now have a folder "scripts" with "cronjob.php":
<?php
define("_CRONJOB_",true);
require(APPLICATION_PATH . '../public/index.php');
// my executions
?>
In my "index.php" file:
if(!defined('_CRONJOB_') || _CRONJOB_ == false)
{
$application->bootstrap()->run();
}
But how can I set this on my server?
I've done the following as a start: chmod 755 cronjob.php, but what's next?
Use crontab, make sure you have both crontab and php-cli installed.
First edit the cron by doing
$ crontab -e
Then insert something like this
*/10 * * * * /usr/bin/php /path/to/scripts/cronjob.php
This examples does execute the script every 10th minute.
For more on the syntax see https://en.wikipedia.org/wiki/Cron#Predefined_scheduling_definitions
Alternate method for setting Cron job on Linux Server
Step 1: Open Terminal
Step 2: Type
$ sudo crontab -e
Enter System Password
Step 3: Put Cron URL to be executed for every 5 minutes interval
*/5 * * * * curl http://testwebsite.com/hitcronscript
Reference: https://crontab.guru/every-5-minutes
*Note: For test purpose one may set mail or file/Db entry.
Hope it will help developers.
I have a cron job that executes once per day:
0 20 * * * /usr/bin/wget --timeout=10800 -O /home/File.txt http://www.site.com/script.php
and so far all was fine, but recently I found out the script just stops.
I looked in the /var/log/httpd/error_log (it's a CentOS) and found this:
[Thu Nov 21 21:30:32 2012] [notice] child pid 8985 exit signal Segmentation fault (11)
Now, this means two things: the script was successfully running for about hour and a half, but then the segmentation fault happened. Ususally the script takes around 2 hours to complete, so it lacks around half an hour to complete it's job.
Now, I can't find the error which causes the script to stop even though I do have error_reporting turned on.
I'm wondering, is there some way so that I can find a potential error line which caused the script to terminate?
I did try google, and SO, ofc, and tried to achieve the same as on this question here on SO by doing this:
0 20 * * * /usr/bin/wget --timeout=10800 -O /home/File.txt http://www.site.com/script.php 2>1& >> /home/log.txt
but the log file is empty. I'm not so good at managing linux so it may be that my command is wrong in this cronjob, so please steer me right.
Try this
0 20 * * * /usr/bin/wget --timeout=10800 \
-O /home/File.txt http://www.site.com/script.php >> /home/log.txt 2>&1
the 2>&1 part tells to send the STDERR to the same place as STDOUT.
Cron sends the output of the command to the email of the user which is executing it.
For this system to work you must have a mail daemon installed, such as exim or postfix.
Also, you are asking wget to write a file in the /home/ directory, i presume as non-root, which means you can't do that. And if you are root you shouldn't do that.
I'm trying to set a cronjob to run every 20 minutes.
This works manually:
php /srv/www/mysite.co.uk/public_html/PP/Make_XML.php LONDON
I tried to use "crontab -e" and set it even to every 20 minutes with:
*/20 * * * * php /srv/www/mysite.co.uk/public_html/PP/Make_XML.php LONDON
it was saved to /tmp/crontab.0xYhei9m/crontab
And it doesn't seem to work.
What's wrong here?
EDIT:
Current stats:
*. cron is up and running:
root 31855 1 0 08:39 ? 00:00:00 /usr/sbin/cron
*. Running "crontab -l" shows:
*/20 * * * * /usr/bin/php /srv/www/mysite.co.uk/public_html/PP/Make_XML.php
LONDON
And still no go. Again manually running the script works just fine.
is the cron daemon even running?
it was saved to /tmp/crontab.0xYhei9m/crontab
Yes - that's the file you just edited - its NOT the file crond reads to fire jobs. Crontab whould then read this file, install the updated crontab in the location where crond looks for it and notify crond it needs to process the file.
Have you checked:
crond is running?
your uid is allowed to schedule cron jobs (usually via /etc/cron.allow / /etc/cron.deny)
that the script really isn't being started by cron and failing due to a permissions error?
that the version of crond you are using support $PATH and can find the executable?
In case this is already online, try using wget instead of php, with the url instead of the path, ie.:
*/20 * * * * wget http://YOUR_IP/~YOUR_USER/PATH/Make_XML.php
or
*/20 * * * * wget http://mysite.co.uk/PP/Make_XML.php
First make sure the url works , just by opening it with a browser
Hope it helps!
Crontab doesn't know anything about PATH variable. So use absolute path to your php (/usr/bin/php for e.g.)/ You can run command which php to find your php path