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? 
- 
 @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. 
- 
 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. 
- 
 One of the nice things is you can look at your timers easily. 
  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. 
- 
 @jaredbusch Also if you have cockpit installed, under services, you can easily create and manage timers too. 
- 
 @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.
- 
 @jaredbusch Very interesting thankyou. I like this way of doing things 
- 
 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
- 
 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.  
- 
 @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-cronI honestly forgot I posted that. 




