Created
June 27, 2018 18:34
-
-
Save rreece/760f50b5caa22afaad150393a1f2c67d to your computer and use it in GitHub Desktop.
Bash script to continuously watch for output files and move them
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/env bash | |
log=mv_files.log | |
spare=/spare/ryan | |
dest=/cb/data/imagenet1k2/new/ | |
while true; do | |
if test -n "$(shopt -s nullglob; echo $spare/*)" | |
then | |
echo "Moving files to $dest" | |
echo "Moving files to $dest" >> $log | |
ls -rt1 $spare | head -n -10 | xargs -n 1 echo | |
ls -rt1 $spare | head -n -10 | xargs -n 1 echo >> $log | |
ls -rt1 $spare | head -n -10 | xargs -I {} mv $spare/{} $dest | |
else | |
echo "$spare is empty" | |
echo "$spare is empty" >> $log | |
fi | |
echo "Sleeping..." | |
echo "Sleeping..." >> $log | |
sleep 1800 ## 1800 s = 30 mins | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment