Hi!
On the main branch I use a con job to activate and deactivate a group. I am now testing v6 and the same cron job does not seem to work. Is that to be expected? Is there a new way to do the same in v6?
Here is my crontab:
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
0 15 * * * sudo sqlite3 /etc/pihole/gravity.db "update 'group' set enabled = 0 where name = 'Kids-Restricted'" && pihole restartdns
0 17 * * * sudo sqlite3 /etc/pihole/gravity.db "update 'group' set enabled = 1 where name = 'Kids-Restricted'" && pihole restartdns
Nothing happens. the group status does not change and I see nothing in the logs.
Another thing I noticed is that the crontab is reset at reboot ie. the lines I added disappear when the container is restarted. To fix that I had to edit /etc/crontabs/root.
Moreover, activating/deactivating a group on the web interface, also fails. gives "bad element ( enabled_2 ) or invalid data-id!”. I am quite sure this was not the case when I tested this on v6 earlier today so might be an unrelated issue.
Okay, so this is likely something else. I'd start with trying to run the commands you want to be run be cron yourself on the terminal and check if there are any error messages.
Ah! A container, this is new information!
Mind that Pi-hole v6.0 is based on Alpine so the issue may be as simple as that sudo is not available and, hence, you commands above probably indeed simply fail (and would have provided a clear error message if tested on the terminal first ).
I agree this looks unrelated. Can you trigger it reliably? Is there something specify you have to do or does it always happen?
Makes a lot of sense indeed
Trying the commands directly gives me "bash: sqlite3: command not found” which is fixed by installing sqlite.
the command pihole restartdns gives an error though [âś—] /usr/local/bin/pihole: line 193: service: command not found. Is it needed btw?
The issue with the web interface happens everytime. now on 2 different installs of pihole v6, one on an RPI5 and another on my Mikrotik router and in different browsers.
Great. Thanks!
Another issue I thought I solved but did not is that my crontab gets reset at reboot. I tried via crontab -e, /etc/crontabs/root, /var/spool/cron/crontabs/root and /var/spool/cron/crontabs.224. none of them persists after reboot.
Instead of adding the cron job into the container, you could have it on the host and run the commands with: docker exec -it [name of pihole container] [command]
MTKAX3:/# man crontab
bash: man: command not found
MTKAX3:/# cd /var/spool/
MTKAX3:/var/spool# ls
cron mail
MTKAX3:/var/spool# cd cron/
MTKAX3:/var/spool/cron# ls
crontabs
MTKAX3:/var/spool/cron# ls -l
total 0
lrwxrwxrwx 1 root root 13 Feb 13 23:17 crontabs -> /etc/crontabs
MTKAX3:/var/spool/cron#