# Pihole Blacklist not working properly when scripted

**URL:** <https://discourse.pi-hole.net/t/pihole-blacklist-not-working-properly-when-scripted/58012>\
**Category:** Community Help\
**Tags:** docker\
**Created:** [September 18, 2022, 11:55pm UTC](https://discourse.pi-hole.net/t/pihole-blacklist-not-working-properly-when-scripted/58012 "2022-09-18T23:55:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anowak](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@anowak](https://discourse.pi-hole.net/u/anowak)\
**Post date:** [September 18, 2022, 11:55pm UTC](https://discourse.pi-hole.net/t/pihole-blacklist-not-working-properly-when-scripted/58012/1 "2022-09-18T23:55:24Z")

</div>

Hi All,

I currently run PiHole as a docker container - see previous post [Move from Full Pihole to Docker - #10 by anowak](https://discourse.pi-hole.net/t/move-from-full-pihole-to-docker/53877/10).

Understand PiHole was not intended for parental control but seemed to be the easiest way to prevent access to social media sites during school days.

The idea is to have a cron job run a script twice a week. Once on Monday morning and then on Friday afternoon. This script would enable or disable the gravity database blacklist table based on the comment with the word "script".

 ![image](https://discourse.pi-hole.net/uploads/default/original/3X/d/1/d1580cd903cb6900eb4b2ac9cd37db14c3a718c7.png)

**Cron Job.**

```auto
00 6 * * Mon /opt/script/enabledisable_domainlist.sh
30 16 * * Fri /opt/script/enabledisable_domainlist.sh

```

**enabledisable\_domainlist.sh**

```auto
#!/bin/bash

dayofweek="$(date +%w)"
# Monday
if [${dayofweek} = "1"]; then
 enabled=1
# Friday
elif [${dayofweek} = "5"]; then
 enabled=0
else
 exit
fi

gravitydb="/etc/pihole/gravity.db"

# Enable/Disable blacklists with script in comment.
pihole-FTL sqlite3 ${gravitydb} "update 'domainlist' SET enabled = '${enabled}' WHERE comment like '%Script%';"

pihole restartdns reload-lists

```

Using docker-compose, I inject the initialisation script into /etc/cont-init.d to create the Cron jobs.

**Initialisation script**

```auto
#!/bin/bash

chmod +x /opt/script/enabledisable_domainlist.sh
crontab /opt/script/cron.txt

```

All seems to work, as the scripts are being triggered correctly and modify the DB.

The issue I am having is that PiHole, even though I have the blocklist enabled through the script - seem to ignore the changes until I manually restart the DNS Service or manually run `*pihole restartdns reload-lists*`.

**Notes:**  
I modified script to take in a variable 0 or 1 to activate and deactivate blacklist - script worked but PiHole still ignored changes until manual steps run??

Wondering if anyone had any ideas how to get PiHole to refresh the changes using scripts? Or is this a Docker issue?

---

<div class="post-metadata">

**Author:** ![system](https://discourse.pi-hole.net/uploads/default/original/3X/7/c/7c8792f649eeb921c5d2b4c41564ffa873d9a2b8.png) [@system](https://discourse.pi-hole.net/u/system)\
**Post date:** [October 9, 2022, 11:55pm UTC](https://discourse.pi-hole.net/t/pihole-blacklist-not-working-properly-when-scripted/58012/2 "2022-10-09T23:55:54Z")

</div>

Closed on October 9, 2022, 11:55pm UTC

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
