Files
2020-03-05 00:08:40 +08:00

43 lines
900 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
#copyright by monlor
source /etc/mixbox/bin/base
# 添加定时任务利用uci来储存信息cru {a|d|c} [name] [crontab]
method="$1"
name="$2"
# content="$3"
case "$method" in
a)
[ -z "$name" -o -z "$3" ] && exit 1
mbdb set mixbox.cru.${name}="$(base_encode "$3")"
;;
d)
[ -z "$name" ] && exit 1
mbdb del mixbox.cru.${name}
;;
c)
mbdb clear mixbox.cru
;;
l)
mbdb show mixbox.cru
;;
esac
# 使定时任务生效
if [ -d /etc/crontabs/ ]; then
cronpath="/etc/crontabs/root"
elif [ -d /var/spool/cron/ ]; then
cronpath="/var/spool/cron/root"
elif [ -d /var/spool/cron/crontabs/ ]; then
cronpath="/var/spool/cron/crontabs/root"
else
logsh "【Tools】" "找不到定时任务文件!" -p
exit 1
fi
sed -i "/#mixbox-cru/d" ${cronpath} &> /dev/null
mbdb values mixbox.cru | while read line; do
echo "$(base_decode "$line") #mixbox-cru" >> ${cronpath}
done
exit 0