Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
can someone give me a hint how to enable the lightweight cron?
Thanks
p.
Comments
Comment #1
jonathan1055 CreditAttribution: jonathan1055 commentedHi papalapapp,
In the scheduler administration pages, there are three tabs - take a look at the one named 'lightweight cron'. The url is admin/config/content/scheduler/cron. This has most of the help you need.
To actually run cron jobs you need to set them up on the webserver - depending on how your site is hosted you may have access to 'crontab' or 'cron jobs' in your host company cpanel, or you might have access to the crontab command directly via terminal or a unix window.
If you do not understand any of the above, then this is outside the scope of drupal, but you should be able to find help on other sites - just google for cron job or crontab, or take a look at http://en.wikipedia.org/wiki/Cron
Hope that helps,
Jonathan
Comment #2
BrianLP CreditAttribution: BrianLP commentedHi Jonathan, thanks for the explanation. I've been reading the cron tab but it didn't tell me anything. I guess what you describe is out of my scope. (I thought it might be configured within the installation like the drupal system cron.)
p.
Comment #3
jonathan1055 CreditAttribution: jonathan1055 commentedHi,
The 'real' drupal system cron still requires you to set up external cron jobs via cpanel or unix. The drupal7 internal core cron is an alternative way to do it, which I think relies on checking the time lapsed since the last run - but this actually requires visitors to retrieve pages from your site. The proper crontab jobs run on the server at specified times and would still run even if no pages were requested.
If you cannot or do not want to set up the external cron jobs for lightweight scheduler, then you can use the core system cron, and the scheduler will do its processing as expected, it's just that you will not have any finer control on the frequency of runs than that provided by the core config options.
Jonathan
Comment #4
jonathan1055 CreditAttribution: jonathan1055 commentedRick, Eric, Pieter
Do you think we need to expand on the help given in the Lightweight Scheduler tab? See the comment in #2. It may not be clear to some users that if they only use the Drupal7 internal cron system and do not implement any external crontab, then they cannot do the same with scheduler lightweight cron.
Jonathan
Comment #5
knalstaaf CreditAttribution: knalstaaf commentedSome hosts provide an option called planned or scheduled tasks. This is usually where you can configure cron jobs as described above. In these cases there's no coding involved. You just need to set the preferred time interval and the url it should run (e.g. domain.com/scheduler/cron), and the host takes care of it.
If there's no such option available, you can try the following with SSH:
cd /etc
)ls
, you should seecrontab
in the listvim crontab
(orcrontab -e
) to edit the crontab* * * * * wget -q -O /dev/null "http://yourdomain.com/scheduler/cron"
:wq
to save and quit.It should work now.
In some cases you can simply download the
.crontab
file with FTP, and edit it with your text editor. Mind you that this is a hidden file, so adjust the visibility settings of your FTP-client and computer accordingly.Comment #6
Cybergrass CreditAttribution: Cybergrass commentedSo, do I have to create a real cron job to fire for each lightweight cron job I enter? That doesn't make any sense. All I can do is enter all the various scheduled articles at various times and then fire off a real cron job to run the lightweight cron after the last scheduled job to make all of the lightweight cron jobs run at the same time (regardless of when they are actually scheduled). However it works is not intuitive and the documentation is lacking.
Comment #7
pfrenssen@Cybergrass, I don't completely understand your question but I will try to explain what I can.
I think you are mistaken about the concept. You cannot "enter lightweight cron jobs". This is simply a single task intended to be run with cron. It's also entirely optional and is only needed if your website requires highly accurate scheduling. This task will publish and unpublish all nodes that are scheduled. It can be launched either by pressing the "Run lightweight cron now" in the administration, or by visiting the web page at the address
/scheduler/cron
.On normal websites this is not needed, since the normal Drupal cron task is sufficient. Every time the normal Drupal cron runs all scheduled nodes will be (un)published.
If your website has specific needs you can optionally choose to use the lightweight cron. If for example you need your pages to be published accurately on-the-minute then it is not advisable to run the standard Drupal cron every minute since this would kill performance. You would configure an additional cron job on the server to visit the
scheduler/cron
website once per minute. This would ensure that your nodes appear exactly on the correct minute they were intended to without dramatically increasing the server load.Note that this is not the recommended way of doing this either, but we include it because it's something that can be made to work on any server. Some people that use shared hosting cannot configure their own cron jobs, so they can still do this by requesting the web pages from another machine.
Calling an actual web page has a lot of unnecessary overhead. It's better to use a module such as Elysia Cron, or some people have reported that they are using Drush to do this, by configuring a cron job on their server to run
drush eval "scheduler_cron();"
.I have trouble understanding this question, so please excuse me if I do not answer it correctly.
Scheduler uses a cron job for publishing and unpublishing nodes. It will publish everything that was scheduled since the last time the cron job has run. So if you configure your server to run the Drupal cron every night at midnight, then you will notice that all nodes that were scheduled to be published during the previous day will be published at midnight.
If you run the Drupal cron every hour, then all the scheduled nodes will be processed every hour. This is accurate enough for most websites and doesn't have too much negative impact on a typical website.
Now, if you need the timing on your scheduling to be respected more accurately than once per hour you can configure your cron job on the server to run more often. But then you cannot run the regular Drupal cron since it will negatively impact the performance of your website. You can then opt to use either Elysia Cron or run the Scheduler specific cron by itself, using Drush or using the Lightweight cron mechanism.
Suggestions on how to improve the documentation are welcome.
The documentation in the README is quite short but explains it quite well I think. It mentions that it will use Drupal's cron by default, and that you can set up your own additional cron if you need more accurate scheduling.
It's also not really our responsibility to teach people how to administer their servers. There is tons of documentation on drupal.org on how to configure cron on a variety of systems.
Comment #8
slefevre1 CreditAttribution: slefevre1 commentedFor anyone who arrived here and was confused after reading all these comments, here's an explanation of how to enable the Scheduler module's lightweight cron. I tested these steps with Scheduler 1.4.
admin/config/content/scheduler/cron
on your Drupal site.Generate New Random Key
/scheduler/cron/your-key-here
. For instance, if your site wasmysite.com
and your key wasasdfoiasjdfoij
, then you would go tohttp://mysite.com/scheduler/cron/asdfoiasjdfoij
Your cron job will look something like this:
wget http://mysite.com/scheduler/cron/asdfoiasjdfoij
Schedule the cron job as often as you want the lightweight scheduler cron to run.
This can be a little confusing because there are actually two crons. That's right! Unix-flavored servers run a service called cron that runs tasks periodically as scheduled. Drupal has it's own "cron", which can be triggered by the webserver's cron (in addition to other ways).
Comment #9
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHi slefevre1,
We don't want people to be confused! I'd be happy to expand on the help text given on the Lightweight Cron page. Here is the current text:
I can see that there are a few assumptions made in this text, like assuming admins know what a cron job is. We could add links for users to read this background information as explaining cron from first principles is a bit out of scope for the Scheduler page.
If you could say more precisely what you were confused about then we should be able to improve the help. Certainly you should not have to resort to reading the issue queue to find out how to do it.
Jonathan
Comment #10
slefevre1 CreditAttribution: slefevre1 commentedHey Jonathan, thanks for the input.
My situation was that I'm a contractor at a new job. I was given a task to set up "lightweight cron", so my first step was to google "Drupal lightweight cron", and I arrived here. (I was unfamiliar with scheduler beforehand).
So probably the help and README for the module is very good. I just didn't know to start there.
When I read this question and all the ensuing conversation, I said "Wow, this sounds really complicated." Then I looked at the page, and once I realized it was actually simple, then I was able to do it.
I posted the steps so that anyone who was less familiar with Drupal (or unix cron) than me could actually come away from this page knowing what to do.
Comment #11
mjdriver CreditAttribution: mjdriver commentedi'm a student and i'm using drupalk 7.
I already read the "read me" , and i understand what you guys mean , but i cant get to the "/scheduler/cron" page. i have my url :
* * * * * wget -q -O /dev/null "http://localhost/drupal7/scheduler/cron/f11d0e58568eaf1779a6" but i cant use it. Because i cant reach the "scheduler/cron" page.
Plz help me, the only patch solutions they give in other issues is for drupal 8 :(
Comment #12
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHi mjdriver,
In the url you quote, you have copied and pasted it from my example in #9, so it will not work as that key is not the one you will be using. If you visit the Scheduler config tabs
admin/config/content/scheduler/cron
you should see your own cron key, or be able to generate one if none exists.Jonathan
Comment #13
mjdriver CreditAttribution: mjdriver commentedYeah i know , i used it as example in my comment.
But i have to set my cron key somewhere, but i can't reach the page where i have to post the cron key.
Do you have an idea where i have to post my key ?
Jannes
Comment #14
mjdriver CreditAttribution: mjdriver commented* * * * * wget -q -O /dev/null "http://jannes.ziedalmorris.be/Planning/scheduler/cron/c1dbb50e00e0ea11e49e"
this is my url that has been generated. Where do i have to set it now ?
Normally i have to set this key somewhere but i can't reach that page
can you help me with it plz.
Now every time i want to publish something i have to excute my cron.
Jannes
Comment #15
loopy1492 CreditAttribution: loopy1492 commentedThank you @slefevre1 . Your instructions are extremely helpful.
Comment #16
steinmb CreditAttribution: steinmb as a volunteer and at University Of Bergen commentedSeems to be answered
Comment #17
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThanks steinmb, yes this can be marked as fixed.
I think I had left it open in case the help on the scheduler cron admin page could be improved. I may still do that, as there are some assumptions there, and a few links to what a cron job is and what is meant by crontab would probably help.
Obviously that will go into Scheduler 2.x now.