Hi,

can someone give me a hint how to enable the lightweight cron?

Thanks
p.

Comments

jonathan1055’s picture

Hi 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

BrianLP’s picture

Hi 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.

jonathan1055’s picture

Hi,
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

jonathan1055’s picture

Rick, 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

knalstaaf’s picture

Issue summary: View changes

Some 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:

  1. Navigate to the etc folder of your project (cd /etc)
  2. If you now type ls, you should see crontab in the list
  3. Type vim crontab (or crontab -e) to edit the crontab
  4. Then add the following line: * * * * * wget -q -O /dev/null "http://yourdomain.com/scheduler/cron"
  5. Hit Esc and type :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.

Cybergrass’s picture

So, 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.

pfrenssen’s picture

@Cybergrass, I don't completely understand your question but I will try to explain what I can.

So, do I have to create a real cron job to fire for each lightweight cron job I enter? That doesn't make any sense.

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();".

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).

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.

However it works is not intuitive and the documentation is lacking.

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.

slefevre1’s picture

For 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.

  1. Navigate to admin/config/content/scheduler/cron on your Drupal site.
  2. If there is no value in the Lightweight cron access key field, click the button labeled Generate New Random Key
  3. Test the key. Copy the value from the field, and then navigate to /scheduler/cron/your-key-here. For instance, if your site was mysite.com and your key was asdfoiasjdfoij, then you would go to http://mysite.com/scheduler/cron/asdfoiasjdfoij
  4. If it worked, you should see nothing in the browser. Check the watchdog log to see that the lightweight cron reported that it started and stopped.
  5. Now, on your website's server, you have to set up a cron job on the server in order to trigger lightweight cron. The server's cron system is completely separate from Drupal's cron.If you don't know how to do this, contact your web server administrator.
    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).

jonathan1055’s picture

Title: How to enable lightweight cron » How to set up Scheduler's lightweight cron

Hi slefevre1,

For anyone who arrived here and was confused after reading all these comments ...

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:

When you have set up Drupal's standard crontab job cron.php then Scheduler will be executed during each cron run. However, if you would like finer granularity to scheduler, but don't want to run Drupal's cron more often then you can use the lightweight cron handler provided by Scheduler. This is an independent cron job which only runs the scheduler process and does not execute any cron tasks defined by Drupal core or any other modules.

Scheduler's cron is at /scheduler/cron and a sample crontab entry to run scheduler every minute might look like:
* * * * * wget -q -O /dev/null "http://localhost/drupal7/scheduler/cron/f11d0e58568eaf1779a6"

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

slefevre1’s picture

Hey 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.

mjdriver’s picture

i'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 :(

jonathan1055’s picture

Hi 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

mjdriver’s picture

Yeah 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

mjdriver’s picture

* * * * * 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

loopy1492’s picture

Thank you @slefevre1 . Your instructions are extremely helpful.

steinmb’s picture

Status: Active » Fixed

Seems to be answered

jonathan1055’s picture

Thanks 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.