You can put a file with a while and perform the concatenation.
Something for this style
#!/bin/bash
RUTA="./ruta" # Esta es una carpeta donde estarán los archivos a concatenar.
ARCHIVO_CONDENSADO="./archivo_condensado"
INTERVALO="3s" #intervalo de tiempo en el formato que acepta el comando sleep
while :
do
cat "$RUTA"/*.txt > "$ARCHIVO_CONDENSADO"
sleep "$INTERVALO"
done
And out of the script, and giving you the execution permission, you just run.
$ nohup ./script &
And the files will be concatenated to one every 3 seconds on writing the file "condensed_file" which is where all the concatenated files will be stored. Although it is very short time has the "potential" that, unlike a cronjob, can be run in fractions of minutes, since a cronjob has the minute as a minimum unit. In that script you can change the value of the interval variable following the format requested by the command sleep
(you can check in man sleep
)
The problem with my script is that, since my few years as a developer, I do not see any meaning to its existence haha;) unless it is a personal exercise. This could be replaced by an instruction from a cronjob.
$ crontab -e
Then it will ask you to edit a file and put something of this style:
* * * * * cat /ruta/a/tu/carpeta/*.txt > /ruta/a/tu/archivo
You save that file that makes you edit the crontab -e
command and with that a task is installed that will be executed every minute which will consist in concatenating all the files from one folder to another file every minute, every day of every month every year. Although that does not make sense either because you concatenate ... And then what ?, Maybe you prefer to make a backup with tar
and, every so often, upload it to a database or store it on the server or something more than about write files of one kind or another.
If you want something that checks and operates according to changes in the contents of the folder or files, you would have to create a journaling class. And if, with these two options previously raised, is not enough, do not hesitate to comment.
Note : I have not run any of the options, I wrote it on the flight so feel free to comment if it did not work.