28 lines
474 B
Bash
Executable File
28 lines
474 B
Bash
Executable File
#!/bin/bash
|
|
|
|
[ -z "$2" ] && { echo 'Usage: $0 "file" "some" "command"
|
|
Runs the command when file exists. waits for max 5 minutes'
|
|
exit
|
|
}
|
|
|
|
fname="$1"
|
|
shift 1
|
|
otime=1
|
|
while :
|
|
do [ -e "$fname" ] || {
|
|
echo -n "File: $fname not found! "
|
|
date
|
|
}
|
|
[ -e "$fname" ] && {
|
|
break
|
|
}
|
|
otime=$(( $otime + 1 ))
|
|
sleep 1
|
|
[ $otime -gt 300 ] && {
|
|
echo "File $fname still missing after 5 minutes!"
|
|
exit 1
|
|
}
|
|
done
|
|
|
|
eval "$@"
|