#!/bin/bash
newdir=/absolute/path/output
olddir=/absolute/path/project
find $olddir -name '*log' | while read line ; do
if [ "$olddir" == "$( basename "$line" )" ] ; then
#just move the file if there are no subdirectories
mv "$line" "$newdir"
else
#1) replace old project dir with nothing
#2) replace all slashes with hashes
#3) set new outdir as prefix
#4) hope that there are no colons in the filenames
prefix="$( sed -e "s:$olddir::" -e 's:/:#:g' -e "s:^:$newdir/:" <<<"$( dirname "$line")" )"
mv "$line" "$prefix"#"$( basename "$line" )"
fi
done
Похоже, вам нужна @reboot
работа.
Затем скрипт мог бы проверить день недели и время суток:
#!/bin/sh
day=$( date +%u ) # day of week as integer, 1 == Monday
tm=$( date +$k ) # time of day, 0-23
if [ "$day" -ne 1 ] || [ "$tm" -lt 7 ] || [ "$tm" -gt 10 ]; then
# wrong day and/or time
exit
fi
# do stuff here