Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Off Topic
    4. crontab funktioniert nicht (Gelöst)

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    crontab funktioniert nicht (Gelöst)

    This topic has been deleted. Only users with topic management privileges can see it.
    • MichaelF
      MichaelF last edited by MichaelF

      Hi, ich habe hier ein kleines Script was ich über die crontab Funktion ausführen möchte.

      # Edit this file to introduce tasks to be run by cron.
      #
      # Each task to run has to be defined through a single line
      # indicating with different fields when the task will be run
      # and what command to run for the task
      #
      # To define the time you can provide concrete values for
      # minute (m), hour (h), day of month (dom), month (mon),
      # and day of week (dow) or use '*' in these fields (for 'any').
      #
      # Notice that tasks will be started based on the cron's system
      # daemon's notion of time and timezones.
      #
      # Output of the crontab jobs (including errors) is sent through
      # email to the user the crontab file belongs to (unless redirected).
      #
      # For example, you can run a backup of all your user accounts
      # at 5 a.m every week with:
      # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
      #
      # For more information see the manual pages of crontab(5) and cron(8)
      #
      # m h  dom mon dow   command
      5 0 * * * /home/pi/evcc-influx-aggregate.sh --yesterday >> /var/log/evcc-grafana-dashboards.log 2>&1
      0 * * * * /home/pi/evcc-influx-aggregate.sh --today >> /var/log/evcc-grafana-dashboards.log 2>&
      

      Das ganze Läuft auf einem Pi3 mit bullseye.

      Problem ist das er das Script nicht ausführt, den Log habe ich bereits aktiviert aber so richtig schlau werde ich daraus auch nicht:

      Oct  4 00:00:01 Influxdb1 CRON[22687]: (pi) CMD (root /home/pi/evcc-influx-aggregate.sh --today >> /var/log/evcc-grafana-dashboards.log 2>&)
      Oct  4 00:00:01 Influxdb1 CRON[22686]: (CRON) info (No MTA installed, discarding output)
      Oct  4 00:05:01 Influxdb1 CRON[22913]: (pi) CMD (root /home/pi/evcc-influx-aggregate.sh --yesterday >> /var/log/evcc-grafana-dashboards.log 2>&1)
      Oct  4 00:05:01 Influxdb1 CRON[22912]: (CRON) info (No MTA installed, discarding output)
      Oct  4 00:17:01 Influxdb1 CRON[23440]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
      Oct  4 01:00:02 Influxdb1 CRON[25350]: (pi) CMD (root /home/pi/evcc-influx-aggregate.sh --today >> /var/log/evcc-grafana-dashboards.log 2>&)
      Oct  4 01:00:02 Influxdb1 CRON[25349]: (CRON) info (No MTA installed, discarding output)
      Oct  4 01:17:01 Influxdb1 CRON[26193]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
      Oct  4 02:00:01 Influxdb1 CRON[28274]: (pi) CMD (root /home/pi/evcc-influx-aggregate.sh --today >> /var/log/evcc-grafana-dashboards.log 2>&)
      Oct  4 02:00:01 Influxdb1 CRON[28273]: (CRON) info (No MTA installed, discarding output)
      Oct  4 02:17:01 Influxdb1 CRON[29083]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
      Oct  4 03:00:01 Influxdb1 CRON[31036]: (pi) CMD (root /home/pi/evcc-influx-aggregate.sh --today >> /var/log/evcc-grafana-dashboards.log 2>&)
      Oct  4 03:00:01 Influxdb1 CRON[31035]: (CRON) info (No MTA installed, discarding output)
      Oct  4 03:10:01 Influxdb1 CRON[31562]: (root) CMD (test -e /run/systemd/system || SERVICE_MODE=1 /sbin/e2scrub_all -A -r)
      Oct  4 03:17:01 Influxdb1 CRON[32089]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
      Oct  4 04:00:01 Influxdb1 CRON[1568]: (pi) CMD (root /home/pi/evcc-influx-aggregate.sh --today >> /var/log/evcc-grafana-dashboards.log 2>&)
      Oct  4 04:00:01 Influxdb1 CRON[1567]: (CRON) info (No MTA installed, discarding output)
      Oct  4 04:17:01 Influxdb1 CRON[2355]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
      Oct  4 05:00:01 Influxdb1 CRON[4285]: (pi) CMD (root /home/pi/evcc-influx-aggregate.sh --today >> /var/log/evcc-grafana-dashboards.log 2>&)
      Oct  4 05:00:01 Influxdb1 CRON[4284]: (CRON) info (No MTA installed, discarding output)
      Oct  4 05:17:01 Influxdb1 CRON[5069]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
      

      Wenn ich in der console eingebe

      /home/pi/evcc-influx-aggregate.sh --yesterday
      

      wird es ausgeführt aber leider nicht im crontab.

      Die Log Datei wird ebenfalls nicht angelegt, warum kann ich ehrlichgesagt auch nicht sagen.

      Wenn noch Infos fehlen, nur sagen.

      Vielleicht hat ja hier jemand eine Idee wo mein Fehler ist, wäre cool.

      Grüße

      Dolomiti 1 Reply Last reply Reply Quote 0
      • Dolomiti
        Dolomiti @MichaelF last edited by

        @michaelf
        Das könnte ein Rechteproblem sein. Ich hatte das auch mal bei einem Skript. Ich weiß aber nicht mehr wie ich das Problem gelöst habe.
        Wie hast du den Eintrag in der crontab erstellt? Mit crontab -e oder mit sudo crontab -e. Das macht einen Unterschied.

        MichaelF 1 Reply Last reply Reply Quote 0
        • MichaelF
          MichaelF @Dolomiti last edited by

          @dolomiti sagte in crontab funktioniert nicht:

          @michaelf
          Das könnte ein Rechteproblem sein. Ich hatte das auch mal bei einem Skript. Ich weiß aber nicht mehr wie ich das Problem gelöst habe.
          Wie hast du den Eintrag in der crontab erstellt? Mit crontab -e oder mit sudo crontab -e. Das macht einen Unterschied.

          Hi, nur mit crontab -e

          ? Meister Mopper 2 Replies Last reply Reply Quote 0
          • ?
            A Former User @MichaelF last edited by

            @michaelf

            Die Antwort, warum es wahrscheinlich nicht geht, steht direkt darunter - "No MTA installed"
            Das wird ja meistens mit "Message Transfer Agent" übersetzt.
            Ich denke der meint, er müsste die Ausgabe irgendwo hinschicken.

            Mach mal Hochkommas um diesen Aufruf in der CRONTAB
            (/home/pi/evcc-influx-aggregate.sh --yesterday), oder lass zum Testen
            das ganze Logzeug in der CRONTAB weg.
            Oder gib wenigstens im Konsolenfenster das mal mit dem Log-Statement ein und nicht nur
            die Hälfte.

            1 Reply Last reply Reply Quote 1
            • Meister Mopper
              Meister Mopper @MichaelF last edited by

              @michaelf sagte in crontab funktioniert nicht:

              Hi, nur mit crontab -e

              Und als welcher User hast du das ausgeführt, hoffentlich nicht als root.

              Der User erstellt seinen Zeitplan mit crontab -e. Soll root dies ausühren, wird vom User sudo crontab -e ausgeführt.
              Ist man jedoch (fälschlicherweise) als root eingeloggt, führt crontab -e logischerweise auch einen root-crontab aus.

              Tel Aviv, Mondamin

              MichaelF 1 Reply Last reply Reply Quote 0
              • MichaelF
                MichaelF @Meister Mopper last edited by

                @meister-mopper

                Nein kein root. pi quasi Standard.

                pi@Influxdb1:~ $ /home/pi/evcc-influx-aggregate.sh --yesterday >> /var/log/evcc-grafana-dashboards.log 2>&1
                -bash: /var/log/evcc-grafana-dashboards.log: Keine Berechtigung
                

                in der tat ein Berechtigungs Problem, wie kann ich das lösen ?

                Thomas Braun 1 Reply Last reply Reply Quote 0
                • Thomas Braun
                  Thomas Braun Most Active @MichaelF last edited by

                  @michaelf sagte in crontab funktioniert nicht:

                  in der tat ein Berechtigungs Problem, wie kann ich das lösen ?

                  Erstmal schauen welche Rechte auf dem File liegen...
                  Bzw. darf der pi mit Sicherheit nicht in das /var/log/evcc-grafana-dashboards.log schreiben. Warum solllte er auch.

                  1 Reply Last reply Reply Quote 0
                  • MichaelF
                    MichaelF last edited by

                    Die Datei habe ich grade mal mit

                    sudo nano
                    

                    erstellt, war ja auch nicht vorhanden.

                    Rechte:

                    -rw-r--r--  1 root     root                    0  5. Okt 18:47 evcc-grafana-dashboards.log
                    
                    Thomas Braun 1 Reply Last reply Reply Quote 0
                    • Thomas Braun
                      Thomas Braun Most Active @MichaelF last edited by

                      @michaelf
                      Dann kannst du es dir ja auch selber beantworten. Der root darf lesen und schreiben, alle anderen nur lesen. Also knallt der kleine pi da vor die Wand.

                      1 Reply Last reply Reply Quote 0
                      • MichaelF
                        MichaelF last edited by MichaelF

                        wäre das dann:

                        chown pi evcc-grafana-dashboards.log
                        

                        und für das schreiben:

                        chmod 660 evcc-grafana-dashboards.log
                        

                        Ich bin leider noch nicht sooooooo firm was das angeht.

                        Thomas Braun 1 Reply Last reply Reply Quote 0
                        • Thomas Braun
                          Thomas Braun Most Active @MichaelF last edited by

                          @michaelf

                          Zunächst mal würde ich sowas nicht in ein /home eines users pflanzen, sondern nach /usr/local/bin
                          Gibt es nicht schon für evcc einen entsprechenden user? Dann würde ich auch den das Skript ausführen lassen.
                          Rechte dann entsprechend an den user oder eine passende Gruppe vergeben.

                          MichaelF 1 Reply Last reply Reply Quote 0
                          • MichaelF
                            MichaelF @Thomas Braun last edited by

                            @thomas-braun

                            Nein auf dem Pi ist quasi nur eine Influx Datenbank, wo aber auch Evcc hineinschreibt.

                            User ist nur der pi vorhanden, das script ist quasi auch ein allgemeines es vereinfacht Grafana das rechnen mit Monats und Jahreswerten die quasi direkt in die Influx Datenbank geschrieben werden.

                            MartinP 1 Reply Last reply Reply Quote 0
                            • MartinP
                              MartinP @MichaelF last edited by

                              @michaelf das ENV innerhalb von cron ist limitiert.
                              Vielleicht fehlt etwas im Pfad.
                              Ich kopiere des Pfad aus dem normalen Terminalfenster oben in die Shell-Scripts, die ich durch cron ausführen lassen will

                              1 Reply Last reply Reply Quote 0
                              • MichaelF
                                MichaelF last edited by

                                Danke an alle, Funktioniert jetzt. Lösung war die Berechtigung.

                                Grüße

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post

                                Support us

                                ioBroker
                                Community Adapters
                                Donate

                                811
                                Online

                                31.7k
                                Users

                                79.7k
                                Topics

                                1.3m
                                Posts

                                6
                                14
                                540
                                Loading More Posts
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes
                                Reply
                                • Reply as topic
                                Log in to reply
                                Community
                                Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                The ioBroker Community 2014-2023
                                logo