Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52dd9997ca | |||
| f59c729c6f | |||
| df04d764c8 |
@@ -1,7 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 [-h <host (hs01*/cloud21)>] [-d <YYYYMMDD> (yesterday*)] [-s <source> (cvttdata/cloud21*)>]"
|
echo -n "Usage: $0 [-h <host (hs01*/cloud21)>]"
|
||||||
|
echo -n " [-d <YYYYMMDD> (yesterday*)]"
|
||||||
|
echo -n " [-s <source> (cvttdata/cloud21*)>]"
|
||||||
|
echo " [-t <target_dir> (/opt/jupyter_gpu/data/crypto_md)]"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,11 +22,15 @@ is_valid() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ------- D E F A U L T S
|
||||||
date=""
|
date=""
|
||||||
host=hs01
|
host=hs01
|
||||||
source=cloud21
|
source=cloud21
|
||||||
|
TargetDir="/opt/jupyter_gpu/data/crypto_md"
|
||||||
|
# ------- D E F A U L T S
|
||||||
|
|
||||||
while getopts ":h:d:s:" opt; do
|
|
||||||
|
while getopts ":h:d:s:t:" opt; do
|
||||||
case ${opt} in
|
case ${opt} in
|
||||||
d )
|
d )
|
||||||
date=$OPTARG
|
date=$OPTARG
|
||||||
@@ -34,6 +41,9 @@ while getopts ":h:d:s:" opt; do
|
|||||||
s )
|
s )
|
||||||
source=$OPTARG
|
source=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
t )
|
||||||
|
TargetDir=$OPTARG
|
||||||
|
;;
|
||||||
\? )
|
\? )
|
||||||
echo "Invalid option: -$OPTARG" >&2
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
usage
|
usage
|
||||||
@@ -82,7 +92,6 @@ SourceFile=$(date -d ${date} "+%Y%m%d.mktdata.db")
|
|||||||
SourceFileZip="${SourceFile}.gz"
|
SourceFileZip="${SourceFile}.gz"
|
||||||
SourceFilePath=$(date -d ${date} "+${SourceRootDir}/%Y/%m/${SourceFileZip}")
|
SourceFilePath=$(date -d ${date} "+${SourceRootDir}/%Y/%m/${SourceFileZip}")
|
||||||
|
|
||||||
TargetDir="/opt/jupyter_gpu/data/crypto_md"
|
|
||||||
TargetFile=$(date -d ${date} "+%Y%m%d.mktdata.ohlcv.db")
|
TargetFile=$(date -d ${date} "+%Y%m%d.mktdata.ohlcv.db")
|
||||||
TargetFilePath="${TargetDir}/${TargetFile}"
|
TargetFilePath="${TargetDir}/${TargetFile}"
|
||||||
|
|
||||||
|
|||||||
@@ -10,17 +10,22 @@
|
|||||||
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 -d YYYMMDD Date> [-O <output dir (./) >]"
|
echo -n "Usage: $0"
|
||||||
|
echo -n " -d YYYMMDD Date>"
|
||||||
|
echo -n " [-O <output dir (./) >]"
|
||||||
|
echo -n " [-S <archive_source_host (cloud21)>]"
|
||||||
|
echo -n " [-D <orig_db_source> (cloud21)]"
|
||||||
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# --------------------- Settings
|
# --------------------- Settings
|
||||||
SourceHost=cloud21.cvtt.vpn
|
SourceHost=cloud21
|
||||||
SourceRootDir=/opt/store/cvtt/md_archive/crypto
|
SourceRootDir=/opt/store/cvtt/md_archive/crypto
|
||||||
DbSource=cloud21
|
DbSource=cloud21
|
||||||
# --------------------- Settings
|
# --------------------- Settings
|
||||||
|
|
||||||
while getopts ":d:O:" opt; do
|
while getopts ":d:O:S:D:" opt; do
|
||||||
case ${opt} in
|
case ${opt} in
|
||||||
d )
|
d )
|
||||||
Date=$OPTARG
|
Date=$OPTARG
|
||||||
@@ -28,6 +33,12 @@ while getopts ":d:O:" opt; do
|
|||||||
O )
|
O )
|
||||||
OutputDir=$OPTARG
|
OutputDir=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
S )
|
||||||
|
SourceHost=$OPTARG
|
||||||
|
;;
|
||||||
|
D )
|
||||||
|
DbSource=$OPTARG
|
||||||
|
;;
|
||||||
\? )
|
\? )
|
||||||
echo "Invalid option: -$OPTARG" >&2
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
usage
|
usage
|
||||||
@@ -46,6 +57,8 @@ fi
|
|||||||
if [ -z ${OutputDir} ] ; then
|
if [ -z ${OutputDir} ] ; then
|
||||||
OutputDir=.
|
OutputDir=.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
SourceHost+=".cvtt.vpn"
|
||||||
mkdir -p ${OutputDir}
|
mkdir -p ${OutputDir}
|
||||||
|
|
||||||
# --- Binance
|
# --- Binance
|
||||||
|
|||||||
+41
-15
@@ -1,36 +1,62 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
echo "Usage: ${0} <log directory> [days (default 2)]"
|
echo -n "Usage: ${0}"
|
||||||
|
echo -n " -L <log directory>"
|
||||||
|
echo -n " [ -A <archive_logs_dir> (default /works/archive/logs)]"
|
||||||
|
echo -n " [-D <older than time criteria> (default: '2 days ago')]"
|
||||||
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
echo Starting $0 $*
|
echo Starting $0 $*
|
||||||
|
|
||||||
LogDir=${1}
|
LogDir=${1}
|
||||||
|
LogArchiveDir=/works/logs
|
||||||
|
DateCriteria="2 days ago"
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------- cmdline
|
||||||
|
while getopts "A:L:D:" opt; do
|
||||||
|
case ${opt} in
|
||||||
|
A )
|
||||||
|
LogArchiveDir=$OPTARG
|
||||||
|
;;
|
||||||
|
L )
|
||||||
|
LogDir=$OPTARG
|
||||||
|
;;
|
||||||
|
D )
|
||||||
|
DateCriteria=$OPTARG
|
||||||
|
;;
|
||||||
|
\? )
|
||||||
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
: )
|
||||||
|
echo "Option -$OPTARG requires an argument." >&2
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
# ---------------- cmdline
|
||||||
|
|
||||||
|
|
||||||
if [ "${LogDir}" == "" ]
|
if [ "${LogDir}" == "" ]
|
||||||
then
|
then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Days=${2}
|
Cmd="mkdir -p ${LogArchiveDir}"
|
||||||
if [ "${Days}" == "" ]
|
echo ${Cmd} && eval ${Cmd}
|
||||||
then
|
|
||||||
Days=2
|
|
||||||
fi
|
|
||||||
|
|
||||||
DateCriteria="${Days} days ago"
|
echo "Looking for log files older than '${DateCriteria}' in ${LogDir}"
|
||||||
|
|
||||||
Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d')
|
Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
echo "Looking for log files older than ${DateCriteria} in ${LogDir}"
|
Cmd="find ${LogDir}/ '(' -name '*.log' -o -name '*.log.*' ')' -type f -not -newermt \"${Oldest}\""
|
||||||
|
echo $Cmd
|
||||||
|
|
||||||
LogArchiveDir=${HOME}/prod/archive/logs
|
files=$(eval ${Cmd})
|
||||||
mkdir -p ${LogArchiveDir}
|
|
||||||
|
|
||||||
echo "find ${LogDir}/ '(' -name '*.log' -o -name '*.log.*' ')' -type f -not -newermt ${Oldest})"
|
|
||||||
files=$(find ${LogDir}/ '(' -name '*.log' -o -name '*.log.*' ')' -type f -not -newermt ${Oldest})
|
|
||||||
if [ "$files" == "" ]
|
if [ "$files" == "" ]
|
||||||
then
|
then
|
||||||
echo "No files found older than ${Oldest} in ${LogDir}"
|
echo "No files found older than ${Oldest} in ${LogDir}"
|
||||||
|
|||||||
Reference in New Issue
Block a user