Last active
June 17, 2023 10:38
-
-
Save garraflavatra/cd3b5861e1c508bcbf9aad58afdb6602 to your computer and use it in GitHub Desktop.
Bash script that keeps all Git repositories within a specified directory up to date.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# | |
# This script keeps all Git repositories within a specified directory up to date. | |
# | |
# Consider the following example. The linux and curl repositories will be updated | |
# when you run this in the gitforks directory. | |
# | |
# gitforks/ | |
# linux/.git/ linux Git repository | |
# curl/.git/ curl Git repository | |
# update.sh This script | |
# last_update.txt Contains last updated time. | |
# | |
# When the script is run, it puts the time of execution and the duration in a file | |
# called last_update.txt | |
# | |
# duration: 0:00.00 | |
# time: Sat Jun 17 12:30:02 CEST 2023 | |
# | |
# You can run this script automatically. For example, add the following to your | |
# crontab to run it every 15 minutes: | |
# | |
# */15 * * * * /home/user/gitforks/update.sh | |
# | |
# (c) Romein van Buren 2023 | |
# SPDX-License-Identifier: WTFPL | |
# | |
set -e | |
cd /home/romein/gitforks | |
\time -f "duration: %E" -o last_update.txt ls -1 -d */ | xargs -P10 -I{} git -C {} pull | |
echo "time: $(date)" >> last_update.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment