Good morning !
I am trying to run the following script every X minutes for Y minutes. Basically, this script outputs a logcat for 5 minutes and checks for files older than 30 minutes to remove them. So far, I haven't found a way to loop this script every 5 minutes beside using watch -n 300 Script.sh
timeout 5m adb shell logcat > ~/ADB/"$(date +%F_%H-%M-%S)".txt
find ~/ADB/ -type f -name '*.txt' -mtime +30m -exec rm {} \;
So far, I have tried with a while loop but it stacks the script every second. The only way it works is using a watch -n 300 Script.sh in a terminal. It lets the script run every 5 minutes for 5 minutes (Then check for files older than 30 minutes to remove them) but I would like to have the whole thing in a single script I can run at bootup.
Edit :
while true;
do
timeout 5m adb shell logcat > ~/ADB/"$(date +%F_%H-%M-%S)".txt
find ~/ADB/ -type f -name '*.txt' -mtime +30m -exec rm {} \;
done
every 5 minutes for 5 minutes
means run the programcontinuously
.... does it not? – jsotola Mar 22 '19 at 01:38