2

I set up the "subscriptions" module and have set it so that all members of the page have access to a number of panels. One allows them to set the frequency of emails, one allows them to pick and choose which nodes to subscribe to. The node choice works well, and so does choosing a 'digest' choice for the emails.

The issue I am having is that the notification emails are sent out at what seems to be the first cron event after the new content has been added, which can be a long time if I don't visit the site, but at the same time too soon if someone has chosen a longer interval.

I am currently the only one 'testing' the site so have two users set up with subscriptions. One I have set for once every 3 hours and one 'once per day'.

As Cron was only running when either entering the site or running manually, I also chose to download the module "Ultimate Cron" which I thought would run Cron more often (i have it set to 30 minutes), but it does not seem to be doing this either, although messages are being sent to both users, even if the one asking for a message no more than once per day has already received one in that 24 hour period.

If I don't visit the site, both now get messages at least, but not at the correct intervals.

One of the main organisers of our organisation says she will not join the forum and member site unless there is a way to get notifications once a day, or once a week, and she is trying to push to use Yahoo forums, but I have everything set up the way I like it and so if I can fix this one issue I can then open it up to members of our small society.

Here are some screenshots of my SUBSCRIPTIONS settings. I have tried to show what I believe is relevant. I have disabled the other subscription modules which I had tried in the past. I DO have some messaging modules though (please see "messaging module" image)

subscriptions module

settings a

settings b

settings c

messaging module

UPDATE: Tested again and still receiving messages on each cron run rather than at the correct intervals. As mentioned below in a comment, it is likely an issue with the Subscriptions module.

If anyone knows how I may be able to fix settings, or even adjust line code to figure this out then I would be very grateful.

Had already tried notifications etc. but Subscriptions is perfect for what I need (if it worked).

Thank you all.

2 Answers 2

1

enter image description here Setting cron to run every 3 hours does not necessarily mean that cron will actually run every 3 hours. This is because it is not truly automatic. Something needs to trigger cron to run. This trigger happens when a user visits the site. As part of dealing with the page request, Drupal will check for the last time that cron has been run and will run cron as part of the request if it is time to do so. If cron is set to run every three hours and three hours has passed since the last time it has run, it will run as part of the page request for the user that happens to hit the page at that time.

But what happens if you have an extremely low traffic Drupal site, application or intranet? If no one visits the site at all, cron will not run. Or if a user visits the site and cron is run, and another user visits the site 2 hours and 59 minutes later, cron will not run because three hours hasn’t passed yet. If a third visitor visits 3 hours later, then cron will run. But that is almost 6 hours since the previous cron run.

Source: Why Drupal cron is not running as often as you think and how to fix it

The solution to this issue is to instead run/trigger cron from your server using crontab.

You can read about it here Why Drupal cron is not running as often as you think and how to fix it and goes over a solution using C-Panel.

If you don't have C-Panel you will have SSH into your server and manually add an entry to your servers crontab:

The automated cron module has the disadvantage that it is triggered by a request, and the unlucky user who sends the request may experience a fairly long delay. For this reason, the automated cron is typically used by smaller sites that are unable to create a cron job manually, e.g. using the Linux crontab. If crontab is desired, Drupal console command may be used to simplify the configuration (rather than curling the long url show in /admin/config/system/cron. Here is an example crontab entry:

30 * * * * web_user /var/www/html/vendor/bin/drupal --
root=/var/www/html/docroot cron:execute > /dev/null 2>&1

This would execute Drupal cron once per hour at 30 minutes after the hour.

Source: Automated Cron

8
  • Thank you No Ssswaet. I will try that and see if it solves all the issues that I am experiencing. Yes, our site will likely have a low volume of activity as we only have a small number of members at this time so running a request from the server seems to be the best solution. I have cpanel, so will look into the options that I have to install this request. I will have to do this over the weekend but will post here once I have done this and done a test. Commented Jan 19, 2019 at 5:23
  • I have successfully changed the cron to run every hour using the CPanel technique. Thank you! HOWEVER, I am still having issues with the notification intervals. I posted in the forum, and an email was sent out to both users at the next cron run (1 am). That was fine as I assumed it was because no previous messages had been sent for longer than the intervals chosen. So, I then created another post. The next cron due at 2am. The user with 'once every day' got a notification email at 2am! The user with 'once every 3 hours' got a notification at 3am! I will add images to post above. Commented Jan 19, 2019 at 18:21
  • I then created another post. The next cron due at 2am. The user with 'once every day' got a notification email at 2am! @Dragonwalker at what time did you create the post?
    – No Sssweat
    Commented Jan 20, 2019 at 0:04
  • at 1:11am, so approx. 10 minutes after the 1am cron run. I have just posted again to see if the same pattern occurs as yesterday. Of course, technically I could get an email at 2am and it would still be 24 hours, so I will post again just after 2am and see if I get yet another email on the 24 hour account sooner. I will post the results in the am. Commented Jan 20, 2019 at 6:02
  • @Dragonwalker at 1:11am well the day changed & just started, so for once every day it makes sense that they got a new notification as soon as cron ran.
    – No Sssweat
    Commented Jan 20, 2019 at 6:05
0

I wanted to update this. Once I had corrected the Cron run, I then reset the subscriptions and then it worked fine. For others struggling, it may also be good to ensure that any changes to the intervals are made BEFORE the categories are chosen, as changes to the intervals will only work with subscription choices made AFTER the change. This may have been part of the issue for the account with the daily option too.

Thank you all for your help.

Now if they would just add a way that interval changes would act on all current subscriptions too. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.