Как выполнить сценарий, как только компьютер будет активен в заданном временном диапазоне и только один раз?

#!/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 
0
22.03.2018, 17:48
1 ответ

Похоже, вам нужна @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
2
28.01.2020, 02:32

Теги

Похожие вопросы