Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédenteDernière révisionLes deux révisions suivantes | ||
floss:config_ubuntu_server_rpi3 [2023/05/03 13:02] – villersd | floss:config_ubuntu_server_rpi3 [2024/01/23 02:53] – villersd | ||
---|---|---|---|
Ligne 7: | Ligne 7: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * janvier 2024 : The simplest way is to use the [[https:// | ||
+ | * [[https:// | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
* [[: | * [[: | ||
+ | * liens adaptés pour Ubuntu 22.04.3 : | ||
+ | * [[https:// | ||
===== Installation ===== | ===== Installation ===== | ||
Ligne 138: | Ligne 142: | ||
* sudo apt-get upgrade | * sudo apt-get upgrade | ||
* sudo apt-get dist-upgrade | * sudo apt-get dist-upgrade | ||
+ | * [[https:// | ||
+ | |||
Ligne 176: | Ligne 182: | ||
<code backup.sh> | <code backup.sh> | ||
- | #!/bin/sh | + | #!/bin/bash |
THESITE=" | THESITE=" | ||
THEDB=" | THEDB=" | ||
Ligne 187: | Ligne 193: | ||
#tar -czf ~/ | #tar -czf ~/ | ||
tar -czf / | tar -czf / | ||
- | # éliminer les fichier vieux de plus de 5 jours → À RETESTER !! | + | # éliminer les fichier vieux de plus de 5 jours |
- | #find / | + | find ~/ |
- | #find / | + | find ~/ |
</ | </ | ||
- | Version après élimination d' | + | Version après élimination d' |
<code backup.sh> | <code backup.sh> | ||
Ligne 206: | Ligne 212: | ||
./backup.sh | ./backup.sh | ||
</ | </ | ||
+ | |||
+ | Part of bash (version >=4.2) script to remove files in a given directory, older than 8 days, but leave files dated the first day of each month : | ||
+ | |||
+ | < | ||
+ | # Set the directory to clean up | ||
+ | DIR=" | ||
+ | |||
+ | # Calculate the cutoff date | ||
+ | CUTOFF=$(date -d "8 days ago" +%s) | ||
+ | |||
+ | # Loop through the files in the directory | ||
+ | for FILE in " | ||
+ | do | ||
+ | # Check if the file is older than 8 days | ||
+ | if [[ -f " | ||
+ | then | ||
+ | # Check if the file's date is the first day of the month | ||
+ | if [[ $(date -r " | ||
+ | then | ||
+ | echo " | ||
+ | else | ||
+ | echo " | ||
+ | rm " | ||
+ | fi | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | </ | ||
+ | |||
+ | Here's how the script works: | ||
+ | - Set the DIR variable to the directory you want to clean up. | ||
+ | - Use the date command to calculate the cutoff date. This will be 8 days ago from today. | ||
+ | - Loop through each file in the directory using a for loop. | ||
+ | - Check if the file is a regular file (-f) and if its modification time is older than the cutoff date. If it is not, then skip to the next file. | ||
+ | - If the file's modification time is older than the cutoff date, check if the file's date is the first day of the month. If it is, then skip to the next file. | ||
+ | - If the file's date is not the first day of the month, then delete the file using the rm command. | ||
Références sur les formats de date : | Références sur les formats de date : |