I have installed the elysia cron module and setup the cron job.
So far I'm running cron jobs mannually. And it is quite time consuming because I have other things to do than run cron every 2 hours. I read the handbooks on cron configurations, but didn't get much, since I'm not a PHP literate person.
How can I make my drupal run cron automatically??? So that I don't have to come back to my site every 2 hours.
You can use the crontab. Usually this can be accessed on your server by running crontab -e in the shell and then adding an entry to specify how frequently to update your site. For example,
0 * * * * wget -O - -q -t 1 http://{your_drupal_server}/cron.php
would run every hour. Replace {your_drupal_server} with the url of your server. The command assumes you have wget installed as well.
These sites may be helpful:
Drupal's page on setting up crontab -
https://www.drupal.org/node/23714
Wiki's page on cron -
http://en.wikipedia.org/wiki/Cron
Related
I am developing a plugin that needs a piece of code to run every hour even if no visitors have been on the site that day.
The goal is to have a plugin that i can activate and that just works without asking the clients to set up a cron-job inside of their server settings.
From what i understand wp-cron is not an option here since it only activates on page visit, i would love to hear some advice on this!
I hope i provided enough info, thanks in advance!
What you can do is use native cron. The native cron job is:
wget -q -O - https://example.org/wp-cron.php?doing_wp_cron >/dev/null 2>&1
Set it to run either every 5, 15, or 30 min depending on amount of server resources you have. I recommend a minimum of 30 min. Make sure to replace https://example.org with your domain and protocol (ssl or non ssl).
If you are using the command line (crontab) and/or the cron service doesn't allow you to change the time automatically. This is the full cron job:
*/5 * * * * wget -q -O - 'https://example.org/wp-cron.php?doing_wp_cron' >/dev/null 2>&1
Replace 5 by the interval you want the cron to run (every 30 min, every 15 min etc.). In this example, the cron is ran every 5 min.
I'm running vTiger 7.0 and I noticed on the first of the month, none of my invoices were created. I then took a look at the Scheduler and noticed that the "Last scan started" and "Last scan ended" fields show that none of the cron jobs had fired in days. The cron jobs are scheduled to fire in 15 minute intervals, with the exception of "RecurringInvoice" which runs every 12 hours.
If I visit /myvtigerinstall/vtigercron.php, the cron jobs will all fire but nobody wants to have to manually run cron jobs!
Has anyone had a similar issue before with vTiger?
I'm not exactly sure how to troubleshoot this error effectively and efficiently. I've checked permissions and they all seem to be in order.
If you've installed vTiger CRM on a dedicated server, you maybe have added a line in linux crontab so that the cron executes...
For instance :
* * * * * sh home/vtiger/vtigerCRM5/apache/htdocs/vtigerCRM/cron/vtigercron.sh
If the cron doesn't launch automatically, it means it's not launched by the cron bot...
Vtiger minimum cron frequency is 15 minutes.
Add the following line in crontab
*/15 * * * * wget -O- --spider "http://vtigercrmurl/vtigercron.php" >/dev/null 2>&1
or use the following free services
https://www.easycron.com/
https://cron-job.org
Gist
I am trying to run a cron job in PHP. But the exec and system functions didn't work. (Because the server administrator doesn't allow me to use these two functions due to the security reasons) However, I still need to use PHP to run it, because the running time is decided by the formula and it's uncertain. As a result, how can I run the cron job without using exec or system function in PHP?
My thought
The only way I have come up with is adding the cron job via the cPanel, which is set to “once per minute.” That means setup a cron job for every minute to check the target PHP page whether it has anything to do at that moment.
Issue
There's a possible issue if it always checks the page every minute per day, won't it damage the host? (Maybe it will cause a damage to CPU or maybe occupy the memory space, etc.) If so, how to improve it?
You can call a bash script containing a call to PHP-CLI and then the file:
#!/usr/bin/php
/path/to/my/php/file.php
Go to the command line of the server and type "which php". Replace /usr/bin/php above with that which is returned. Then you call this bash script in your CRON.
As you say you have a cpanel server, im guessing its a linux box. You run a cronjob from a linux box by typing crontab -e and then to run a php script. */5 * * * * /usr/bin/php /path/to/file.php to un it every 5 minutes.
I have worked on creating a plugin for setting a cron job. However it runs only when a person visits it. Can we link it with linux so that it opens the site and the cron job is done without anyone visiting the page. How can we use wget for this if the wordpress is set up locally?
Do this following steps to get your server cron going, enable server cron from plugin is not possible as of now (as i understand).
Disable wp-cron.php
You can disable WP-cron by modifying the wp-config.php (located in the folder where WordPress is installed). Open the wp-config.php file, add a new line after
define('DISABLE_WP_CRON', true);
Set Up a Linux Cron
Warning: It is important that you familiarize yourself with how cron
jobs work. You need to have a working knowledge of Linux commands
before you can use cron jobs effectively.
To set up a Linux cron job:
Log into your cPanel.
In the Advanced section, click Cron jobs.
Under Add New Cron Job, select the time interval. HostGator recommends that you do not set the interval lower than 15 minutes.
Set the cron command to the following, replacing yourwebsite.com with your actual domain name:
wget -q -O - http://yourwebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
The above command tells the Linux server to run wp-cron via wget, which will trigger the wp-cron.php script to do it's job on your schedule instead of on each page view.
Click Add New Cron Job to set the cron.
In order to test out the new cron, simply wait for the elapsed time period for the cron to run. In the event that the cron does not run, please review the steps listed above to ensure that you have completed all steps correctly.
CREDITS:
http://support.hostgator.com/articles/specialized-help/technical/wordpress/how-to-replace-wordpress-cron-with-a-real-cron-job
You can schedule a cronjob.
$ crontab -e
*/1 * * * * curl -I http://example.org/wp-cron.php?doing_wp_cron
the last days I have researched about cron jobs. First I want to tell you abaout my problem.
I want to run a php script on my webserver every minute without loading the page. this php script inserts some data via yql. I read that cron is just working with unix/linux. my server runs on unix (wait for it). is it now possible for me to let my script run while sleeping in bed (computer off) just by the server side? do I got this all right? if yes, I also have to know how the path have to be look like in my command part in my schedule, because every example contents something like "* */1 * * * /usr/bin/wget http://www.example.com/cron.php", but why there is /usr/bin/wget in the path (that means, this cron is running just from my computer system not from the webserver) and how to put my schedule on the server and better where. my server have the root public_html where my index.php is inside. please give me an example of the schedule and how to fire my php data called "to_fire.php" that puts the data on my database via mysql.
I hope that some of you know what I exactly mean by own experience. im kinda confused by this command part and how to let it run from just the webserver and not my computer system.
thanks
wget is a unix command to visit a web URL. curl is another command working similarly. You could also use php path\to\script.php to run, as Gigawatt mentioned. There is no big difference from all of them
* */1 * * * is to set cron timing.
/usr/bin/wget is the location where wget on your server
Yes, once cron set, you can leave it alone. As long as server is living, the cron will run as scheduled. You can even set cron to send you an email, but that's no applicable to your case as running per min is to short.
Running cron per min seems not common. If you are doing something like realtime update, consider other solution.
Cron can be set on cPanel.
You need to config your cron script to accept request from same server only, to avoid others access this URL.
Some resource for cron
Configuring cron jobs in cPanel http://drupal.org/node/369267
Backup Databases using a cron http://wiki.lunarpages.com/Backup_Databases_using_a_cron
Configuring cron jobs using the cron command http://drupal.org/node/23714
Managing Cron Jobs with PHP http://net.tutsplus.com/tutorials/php/managing-cron-jobs-with-php-2/