Gravity Job - Intervall anpassen !?

Hallo zusammen,

der Job für die Aktualisierung der Blocklisten läuft standardmäig von Samstag auf Sonntag Nacht zwischen 3 und 5 Uhr morgens.

Wie kann ich den Job anpassen nach individuellen Wünschen?

Weiß das jemand ?

pi@ph5a:~ $ cat /etc/cron.d/pihole
[..]
# Pi-hole: Update the ad sources once a week on Sunday at a random time in the
#          early morning. Download any updates from the adlists
#          Squash output to log, then splat the log to stdout on error to allow for
#          standard crontab job error handling.
6 4   * * 7   root    PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole/pihole_updateGravity.log || cat /var/log/pihole/pihole_updateGravity.log
pi@ph5a:~ $ man cron
[..]
NAME
       cron - daemon to execute scheduled commands (Vixie Cron)
[..]
       Additionally, in Debian,  cron  reads  the  files  in  the
       /etc/cron.d   directory.    cron   treats   the  files  in
       /etc/cron.d as in the same way as  the  /etc/crontab  file
       (they  follow  the  special format of that file, i.e. they
       include the user field).
[..]
SEE ALSO
       crontab(1), crontab(5), run-parts(8)
pi@ph5a:~ $ man 5 crontab
[..]
       The format of a cron command is very much the V7 standard,
       with  a number of upward-compatible extensions.  Each line
       has five time and date fields, followed by a command, fol‐
       lowed  by  a newline character ('\n').  The system crontab
       (/etc/crontab) uses the same format, except that the user‐
       name  for the command is specified after the time and date
       fields and before the command.  The fields  may  be  sepa‐
       rated by spaces or tabs.  The maximum permitted length for
       the command field is 998 characters.

       Commands are executed by cron(8) when  the  minute,  hour,
       and  month of year fields match the current time, and when
       at least one of the two day fields (day of month,  or  day
       of  week)  match  the  current  time (see ``Note'' below).
       cron(8) examines cron entries once every minute.  The time
       and date fields are:

              field          allowed values
              -----          --------------
              minute         0–59
              hour           0–23
              day of month   1–31
              month          1–12 (or names, see below)
              day of week    0–7 (0 or 7 is Sun, or use names)

       A  field  may  be an asterisk (*), which always stands for
       ``first-last''.

Danke, aber ich erkenne jetzt nicht wie ich es anpassen kann.

Wie und was muss ich editieren damit der Job täglich um 5 Uhr morgens läuft?

Mine is scheduled at 4:42 hours every Sunday (7):

pi@ph5a:~ $ grep updateGravity  /etc/cron.d/pihole
42 4   * * 7   root    PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole/pihole_updateGravity.log || cat /var/log/pihole/pihole_updateGravity.log

To change to 5:00 hour:

pi@ph5a:~ $ sudo sed -i '/updateGravity/ s/^.*root/0 5   * * 7   root/' /etc/cron.d/pihole
pi@ph5a:~ $

Check:

pi@ph5a:~ $ grep updateGravity /etc/cron.d/pihole
0 5   * * 7   root    PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole/pihole_updateGravity.log || cat /var/log/pihole/pihole_updateGravity.log

EDIT: I changed the sed command a bit bc of the weird spacing!

Danke, also wenn ich das täglich um 5 Uhr machen möchte.. .ist das dann richtig?

sudo sed -i '/updateGravity/ s/^.*root/0 5   * * *   root/' /etc/cron.d/pihole
1 Like

Spot on.

But why?
Weekly is the recommended default.

Oh sorry, the asterixes "*" should be escaped with a backslash "\" bc of special meaning.
So it becomes:

sudo sed -i '/updateGravity/ s/^.*root/0 5 \* \* \* root/' /etc/cron.d/pihole

Ah bullocks, I believe above only applies for the matching criteria.
So below will do fine:

sudo sed -i '/updateGravity/ s/^.*root/0 5 * * * root/' /etc/cron.d/pihole

Ok, Änderung:

sudo sed -i '/updateGravity/ s/^.*root/0 5 * * * root/' /etc/cron.d/pihole

Check:

grep updateGravity /etc/cron.d/pihole

Result:

0 5 * * * root    PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole/pihole_updateGravity.log || cat /var/log/pihole/pihole_updateGravity.log

Ok there is a difference between posting below:

0 5   * * *   root

Vs:

0 5 * * * root

Messing with the spaces in my sed :wink:

This is correct one:

sudo sed -i '/updateGravity/ s/^.*root/0 5   * * *   root/' /etc/cron.d/pihole

EDIT: But why?

Thanks!

I just want a daily gravity update :slight_smile:

8 posts were split to a new topic: Gravity-Updates bei ausgeschaltetem Rechner?

Das ist ein ganz normaler Cron-Job, der mit den üblichen Tools geändert werden kann. deHakkelaar hat Dich diesbezüglich ja bereits mit den passenden Infos versorgt.

Noch ein Hinweis zum Update-Intervall:
Viele Blocklisten werden nicht täglich aktualisiert, zudem ist die Update-Frequenz individuell pro Blockliste stark unterschiedlich, von bedarfsweise über einmal pro Woche bis einmal pro Monat oder seltener.
Zudem werden Blocklisten häufig von Personen zusammengestellt und angeboten, die nur über begrenzte Online-Ressourcen verfügen.
Wenn deren Limit erschöpft ist, kann es sein, dass die Blocklist-Inhalte nicht mehr abrufbar sind, schlimmstenfalls für alle Nutzer.

Wenn Du nun bei Dir die Abruf-Frequenz auf einmal täglich anpasst, erhöhst Du potentiell den Verbrauch des Blocklisten-Betreibers, und das möglicherweise ohne zusätzlichen Nutzen.

Es würde also von der jeweiligen Auswahl von Blocklisten abhängen, ob eine Anpassung sinnvoll sein kann.

1 Like

Hi @Bucking_Horn

danke für deine Ausführungen. Vor diesem Hintergrund überlege ich, das Update nur alle 2 - 3 Tage zu machen.
Kannst du mir sagen, wie genau der Befehl dann heißen müsste?

I have to look this one up :wink:

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