mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-10 23:41:22 +00:00
~继续优化定时任务功能
This commit is contained in:
@@ -10,17 +10,19 @@ touch "$tmpcron"
|
||||
cronadd() { #定时任务工具
|
||||
if crontab -h 2>&1 | grep -q '\-l'; then
|
||||
crontab "$1"
|
||||
else
|
||||
elif [ -f "$crondir/$USER" ];then
|
||||
cat "$1" >"$crondir"/"$USER" && cru a REFRESH "0 0 1 1 * /bin/true" 2>/dev/null
|
||||
else
|
||||
echo "找不到可用的crond或者crontab应用!No available crond or crontab application can be found!"
|
||||
fi
|
||||
}
|
||||
cronload() { #定时任务工具
|
||||
if [ -f "$crondir/$USER" ];then
|
||||
cat "$crondir"/"$USER" 2>/dev/null
|
||||
elif crontab -h 2>&1 | grep -q '\-l'; then
|
||||
if crontab -h 2>&1 | grep -q '\-l'; then
|
||||
crontab -l
|
||||
elif [ -f "$crondir/$USER" ];then
|
||||
cat "$crondir"/"$USER" 2>/dev/null
|
||||
else
|
||||
echo "找不到可用的crond或者crontab应用!No available crond or crontab application can be found!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
cronset() { #定时任务设置
|
||||
|
||||
@@ -21,8 +21,6 @@ if [ -n "$test" -o -n "$(pidof CrashCore)" ]; then
|
||||
[ "$start_old" = "ON" ] && [ ! -L "$TMPDIR"/CrashCore ] && rm -f "$TMPDIR"/CrashCore #删除缓存目录内核文件
|
||||
. "$CRASHDIR"/starts/fw_start.sh #配置防火墙流量劫持
|
||||
date +%s >"$TMPDIR"/crash_start_time #标记启动时间
|
||||
#TG机器人守护进程
|
||||
[ "$bot_tg_service" = ON ] && . "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_cron
|
||||
#后台还原面板配置
|
||||
[ -s "$CRASHDIR"/configs/web_save ] && {
|
||||
. "$CRASHDIR"/libs/web_restore.sh
|
||||
@@ -35,13 +33,14 @@ if [ -n "$test" -o -n "$(pidof CrashCore)" ]; then
|
||||
} &
|
||||
ckcmd mtd_storage.sh && mtd_storage.sh save >/dev/null 2>&1 #Padavan保存/etc/storage
|
||||
#加载定时任务
|
||||
[ -s "$CRASHDIR"/task/cron ] && cronadd "$CRASHDIR"/task/cron
|
||||
[ -s "$CRASHDIR"/task/running ] && {
|
||||
cronload | grep -v '^$' | grep -vF "运行时每" >/tmp/cron_tmp
|
||||
cat "$CRASHDIR"/task/running >> /tmp/cron_tmp
|
||||
cronadd /tmp/cron_tmp
|
||||
}
|
||||
[ "$start_old" = "ON" ] && cronset '保守模式守护进程' "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh shellcrash #ShellCrash保守模式守护进程"
|
||||
cronload | grep -v '^$' > "$TMPDIR"/cron_tmp
|
||||
[ -s "$CRASHDIR"/task/cron ] && cat "$CRASHDIR"/task/cron >> "$TMPDIR"/cron_tmp
|
||||
[ -s "$CRASHDIR"/task/running ] && cat "$CRASHDIR"/task/running >> "$TMPDIR"/cron_tmp
|
||||
[ "$bot_tg_service" = ON ] && echo "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh bot_tg #ShellCrash-TG_BOT守护进程" >> "$TMPDIR"/cron_tmp
|
||||
[ "$start_old" = ON ] && echo "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh shellcrash #ShellCrash保守模式守护进程" >> "$TMPDIR"/cron_tmp
|
||||
awk '!x[$0]++' "$TMPDIR"/cron_tmp > "$TMPDIR"/cron_tmp2 #删除重复行
|
||||
cronadd "$TMPDIR"/cron_tmp2
|
||||
rm -f "$TMPDIR"/cron_tmp "$TMPDIR"/cron_tmp2
|
||||
#加载条件任务
|
||||
[ -s "$CRASHDIR"/task/afstart ] && { . "$CRASHDIR"/task/afstart; } &
|
||||
[ -s "$CRASHDIR"/task/affirewall -a -s /etc/init.d/firewall -a ! -f /etc/init.d/firewall.bak ] && {
|
||||
|
||||
Reference in New Issue
Block a user