默认定时改为随机时间

This commit is contained in:
hanhh 2021-08-21 19:26:37 +08:00
parent f7cffe3d2d
commit 61e41269ba
2 changed files with 9 additions and 2 deletions

View File

@ -64,6 +64,7 @@ import_config() {
command_timeout_time=${CommandTimeoutTime:-"1h"}
github_proxy_url=${GithubProxyUrl:-""}
file_extensions=${RepoFileExtensions:-"js py"}
default_cron="$(random_range 0 59) $(random_range 0 23) * * *"
}
make_dir() {
@ -302,6 +303,12 @@ reset_romote_url() {
fi
}
random_range() {
local beg=$1
local end=$2
echo $((RANDOM % ($end - $beg) + $beg))
}
init_env
detect_termux
detect_macos

View File

@ -120,7 +120,7 @@ add_cron() {
[[ -z $cron_name ]] && cron_name="$file_name"
[[ -z $cron_line ]] && cron_line=$(grep "cron:" $file | awk -F ":" '{print $2}' | head -1 | xargs)
[[ -z $cron_line ]] && cron_line=$(grep "cron " $file | awk -F "cron \"" '{print $2}' | awk -F "\" " '{print $1}' | head -1 | xargs)
[[ -z $cron_line ]] && cron_line="0 6 * * *"
[[ -z $cron_line ]] && cron_line="$default_cron"
result=$(add_cron_api "$cron_line:$cmd_task $file:$cron_name")
echo -e "$result"
if [[ $detail ]]; then
@ -210,7 +210,7 @@ update_raw() {
[[ -z $cron_name ]] && cron_name="$raw_file_name"
[[ -z $cron_line ]] && cron_line=$(grep "cron:" $raw_file_name | awk -F ":" '{print $2}' | head -1 | xargs)
[[ -z $cron_line ]] && cron_line=$(grep "cron " $raw_file_name | awk -F "cron \"" '{print $2}' | awk -F "\" " '{print $1}' | head -1 | xargs)
[[ -z $cron_line ]] && cron_line="0 6 * * *"
[[ -z $cron_line ]] && cron_line="$default_cron"
if [[ -z $cron_id ]]; then
result=$(add_cron_api "$cron_line:$cmd_task $filename:$cron_name")
echo -e "$result\n"