ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    How to use a systemd timer instead of cron to automate a git pull

    Scheduled Pinned Locked Moved IT Discussion
    systemdtimercronfedorarhelgit pullgitsystemd timers
    13 Posts 6 Posters 3.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ObsolesceO
      Obsolesce
      last edited by

      Good info. I can see the benefits of running things this way with SaltStack!
      Time to change some States.

      1 Reply Last reply Reply Quote 1
      • black3dynamiteB
        black3dynamite
        last edited by

        Could that be one of the reasons why Fedora 28 minimal doesn’t include cronie because of systemd?

        1 Reply Last reply Reply Quote 0
        • black3dynamiteB
          black3dynamite
          last edited by

          I wonder how well systemd would work with nextcloud background jobs instead of cron?

          JaredBuschJ 1 Reply Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch @black3dynamite
            last edited by

            @black3dynamite said in How to use a systemd timer instead of cron to automate a git pull:

            I wonder how well systemd would work with nextcloud background jobs instead of cron?

            Should work fine. I’ll have to try that next time I mess with one.

            1 Reply Last reply Reply Quote 1
            • travisdh1T
              travisdh1
              last edited by

              I'd think systemd timers will be the proper way to do scheduled tasks in the future. Seems a lot more flexible than cron at first glance.

              1 Reply Last reply Reply Quote 0
              • JaredBuschJ
                JaredBusch
                last edited by JaredBusch

                One of the nice things is you can look at your timers easily.
                0_1534777832623_b678d47e-5f53-4236-98ae-403adf3e4987-image.png

                And the results are viewable in the systemd logs

                [root@bpbx ~]# journalctl -u gitpull.service
                Aug 20 08:00:03 bpbx.domain.com systemd[1]: Started update /tftpboot with git pull.
                Aug 20 08:00:03 bpbx.domain.com systemd[1]: Starting update /tftpboot with git pull...
                Aug 20 08:00:11 bpbx.domain.com git[24804]: Already up-to-date.
                Aug 20 09:00:03 bpbx.domain.com systemd[1]: Started update /tftpboot with git pull.
                Aug 20 09:00:03 bpbx.domain.com systemd[1]: Starting update /tftpboot with git pull...
                Aug 20 09:00:03 bpbx.domain.com git[982]: ssh_exchange_identification: Connection closed by remote host
                Aug 20 09:00:03 bpbx.domain.com systemd[1]: gitpull.service: main process exited, code=exited, status=1/FAILURE
                Aug 20 09:00:03 bpbx.domain.com git[982]: fatal: Could not read from remote repository.
                Aug 20 09:00:03 bpbx.domain.com git[982]: Please make sure you have the correct access rights
                Aug 20 09:00:03 bpbx.domain.com git[982]: and the repository exists.
                Aug 20 09:00:03 bpbx.domain.com systemd[1]: Unit gitpull.service entered failed state.
                Aug 20 09:00:03 bpbx.domain.com systemd[1]: gitpull.service failed.
                Aug 20 10:00:01 bpbx.domain.com systemd[1]: Started update /tftpboot with git pull.
                Aug 20 10:00:01 bpbx.domain.com systemd[1]: Starting update /tftpboot with git pull...
                Aug 20 10:00:11 bpbx.domain.com git[9145]: Already up-to-date.
                

                Looks like it failed for some reason at 9am, but ran fine at 8 and 10.

                black3dynamiteB 1 Reply Last reply Reply Quote 2
                • black3dynamiteB
                  black3dynamite @JaredBusch
                  last edited by

                  @jaredbusch Also if you have cockpit installed, under services, you can easily create and manage timers too.

                  JaredBuschJ 1 Reply Last reply Reply Quote 0
                  • JaredBuschJ
                    JaredBusch @black3dynamite
                    last edited by

                    @black3dynamite said in How to use a systemd timer instead of cron to automate a git pull:

                    @jaredbusch Also if you have cockpit installed, under services, you can easily create and manage timers too.

                    These specific examples are FreePBX installs. not going to mess a lot with the install.
                    Though I did have to install git from yum.

                    jmooreJ 1 Reply Last reply Reply Quote 1
                    • jmooreJ
                      jmoore @JaredBusch
                      last edited by

                      @jaredbusch Very interesting thankyou. I like this way of doing things

                      1 Reply Last reply Reply Quote 0
                      • JaredBuschJ
                        JaredBusch
                        last edited by JaredBusch

                        Oh look I just found this posted here already /sigh..

                        So many questions I could have not asked of @stacksofplates, had I recalled this thread.
                        https://mangolassi.it/topic/13455/systemd-timers-instead-of-cron

                        stacksofplatesS 1 Reply Last reply Reply Quote 2
                        • JaredBuschJ
                          JaredBusch
                          last edited by

                          And looks like I'm going to have to make my git pull into a scrupt and make it smarter because this is not a great success rate IMO.

                          0_1535130418624_5b1fb4dd-8cd8-4399-b140-b721a0d26ca2-image.png

                          1 Reply Last reply Reply Quote 1
                          • stacksofplatesS
                            stacksofplates @JaredBusch
                            last edited by

                            @jaredbusch said in How to use a systemd timer instead of cron to automate a git pull:

                            Oh look I just found this posted here already /sigh..

                            So many questions I could have not asked of @stacksofplates, had I recalled this thread.
                            https://mangolassi.it/topic/13455/systemd-timers-instead-of-cron

                            I honestly forgot I posted that.

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