# How to force grant all badges from command line?

**URL:** <https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960>\
**Category:** Product Support\
**Tags:** badges\
**Created:** [January 7, 2020, 12:14pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960 "2020-01-07T12:14:06Z")\
**Posts on this page:** 20\
**Page:** 1

## AI-generated summary

The user [meglio](/t/-/137960/1) sought help on forcing badge grants from the command line on their production Discourse instance, forum.kozovod.com. Initially, they couldn't find any `grant`-related jobs in Sidekiq's scheduled tasks, suspecting a Docker or plugin issue. [david](/t/-/137960/2) guided them to check the **Scheduler** tab instead of **Scheduled**, where they found the relevant jobs. After triggering the `Jobs::BadgeGrant` job manually, badges were successfully granted. [meglio](/t/-/137960/1) noted that the process took 10k seconds, prompting [david](/t/-/137960/19) to suggest optimizing custom SQL queries, which [meglio](/t/-/137960/20) confirmed resolved the issue, reducing the time to ~1k seconds.

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [January 7, 2020, 12:14pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/1 "2020-01-07T12:14:07Z")

</div>

Badges are granted once per day.  
Is there a way to schedule / force the granting process “right now” from command line?

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [January 7, 2020, 12:15pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/2 "2020-01-07T12:15:10Z")

</div>

Easiest way is to visit `/sidekiq/scheduler` and look for any jobs with the word “grant” in the name. You probably want `Jobs::BadgeGrant`, but some badges have their own tasks.

---

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [January 7, 2020, 12:18pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/3 "2020-01-07T12:18:34Z")

</div>

I went through all scheduled tasks in sidekiq up to 24 hours from now, and none have `grant` token in them.

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [January 7, 2020, 12:20pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/4 "2020-01-07T12:20:54Z")

</div>

Oh… weird. So you don’t see a line like this?

 ![Screenshot 2020-01-07 at 12.20.26](https://global.discourse-cdn.com/meta/original/3X/2/c/2cee9b0479e5c042a13e76abbed820b0d1e5f9e3.png)

Is this a development server, or production?

---

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [January 7, 2020, 12:26pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/5 "2020-01-07T12:26:39Z")

</div>

It’s in production [forum.kozovod.com](http://forum.kozovod.com).  
Correct, no entries like on your screenshot.

I just noticed I had no badges granted for a long time. Rebuilding the container now and will check if the task will be scheduled after restart.

Also, I noticed that one of my custom-sql badges had an error - could it stop all other badges from working?

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [January 7, 2020, 12:33pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/6 "2020-01-07T12:33:03Z")

</div>

> [@meglio](#):
>
> Also, I noticed that one of my custom-sql badges had an error - could it stop all other badges from working?

In theory, no.

I think the most likely thing is a docker-manager update gone wrong, and so some sidekiq jobs had failed to load. Hopefully once you rebuild it will work.

---

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [January 7, 2020, 12:38pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/7 "2020-01-07T12:38:07Z")

</div>

Okay, rebuild went well.

However, in a few minutes after it is complete, I still can’t find any `grant` token in all 125+ scheduled tasks. Does it mean something is failing with my setup?

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [January 7, 2020, 12:38pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/8 "2020-01-07T12:38:44Z")

</div>

Yes, probably. Do you have any errors in `/logs`? Any unusual plugins?

---

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [January 7, 2020, 12:44pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/9 "2020-01-07T12:44:51Z")

</div>

Hm nothing critical in the latest ~20 minutes:

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/f/7f8803193cc6ed9f751c187499e625a597ddbacf.png)

Can you see anything suspicious that can break the badges execution / scheduling?

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [January 7, 2020, 12:50pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/10 "2020-01-07T12:50:15Z")

</div>

Can’t see anything obvious. If you go into a console and type `Jobs::BadgeGrant`, what happens? Should look like this:

```plaintext
[1] pry(main)> Jobs::BadgeGrant
=> Jobs::BadgeGrant

```

---

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [January 7, 2020, 12:59pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/12 "2020-01-07T12:59:17Z")

</div>

Okay here it is:

 ![image](https://global.discourse-cdn.com/meta/original/3X/6/2/62502c59a9b806d00ed9e321dfc9136289cc92eb.png)

After that, no new errors in /logs.

Nor are there new entries with the `grant` token in `/sidekiq/scheduled`

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [January 7, 2020, 1:03pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/13 "2020-01-07T13:03:26Z")

</div>

Do you have any plugins which could be interfering?

---

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [January 7, 2020, 1:06pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/14 "2020-01-07T13:06:25Z")

</div>

here are enabled ones - I try to use popular and supported ones only:

```plaintext
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-data-explorer.git
          - git clone https://github.com/discourse/discourse-staff-notes.git
          - git clone https://github.com/joebuhlig/discourse-feature-voting.git
          - git clone https://github.com/discourse/discourse-checklist.git
          - git clone https://github.com/discourse/discourse-cakeday.git
          - git clone https://github.com/discourse/discourse-saved-searches.git
          - git clone https://github.com/discourse/discourse-canned-replies.git
          - git clone https://github.com/discourse/discourse-assign.git
          - git clone https://github.com/discourse/discourse-bbcode.git
          - git clone https://github.com/angusmcleod/discourse-locations.git
          - git clone https://github.com/discourse/discourse-adplugin.git
          - git clone https://github.com/angusmcleod/discourse-custom-wizard.git

```

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [January 7, 2020, 1:13pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/15 "2020-01-07T13:13:23Z")

</div>

> [@meglio](#):
>
> scheduled tasks in sidekiq up to 24 hours from now

Just checking - are you looking in “Scheduled” or “Scheduler”? The badge jobs should be under **Scheduler**.

(Aside: wow that’s confusing naming!)

 ![Screenshot 2020-01-07 at 13.12.15](https://global.discourse-cdn.com/meta/original/3X/f/6/f629b5f09f4b3349e8a1ffff413311c1e3096682.png)

---

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [January 7, 2020, 1:16pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/16 "2020-01-07T13:16:54Z")

</div>

Thanks.  
Under Scheduler, I can now see the following ones:

- Jobs::GrantNewUserOfTheMonthBadges
- Jobs::GrantAnniversaryBadges
- Jobs::BadgeGrant

All Scheduler jobs apper under the " Recurring Jobs" section.

Now, is it safe for me to click on the “Trigger” button and see what happens?

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [January 7, 2020, 1:31pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/17 "2020-01-07T13:31:54Z")

</div>

Ah good - that makes this much simpler to solve!

Yes, the trigger button is safe 🙂

---

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [January 7, 2020, 1:33pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/18 "2020-01-07T13:33:38Z")

</div>

Thanks, running now.

Last time it took 10k seconds, so will check back tomorrow morning.

Is there any way to process one particular badge? Maybe from command line?

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [January 7, 2020, 1:38pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/19 "2020-01-07T13:38:33Z")

</div>

10k seconds is a lot! On meta, it takes 500 seconds. Maybe one of your custom badge queries is not very efficient? (that’s why we disable the custom SQL feature by default)

---

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [January 7, 2020, 1:57pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/20 "2020-01-07T13:57:50Z")

</div>

Thanks, I reviewed queries quickly and fixed one a bit and it only took ~1k seconds now. I also cross-posted my SQL-optimization question in a separate topic.

Back to the badges - it now worked and all badges are granted. Thank you for your assistance and prompt replies.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [November 2, 2023, 12:26pm UTC](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960/21 "2023-11-02T12:26:48Z")

</div>

Automatically bumped on November 2, 2023, 12:26pm UTC



[Next page](https://meta.discourse.org/t/how-to-force-grant-all-badges-from-command-line/137960.md?page=2)
