mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-11 07:51:45 +00:00
~优化定时任务
This commit is contained in:
@@ -6,11 +6,12 @@ crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}')"
|
|||||||
tmpcron="$TMPDIR"/cron_tmp
|
tmpcron="$TMPDIR"/cron_tmp
|
||||||
|
|
||||||
croncmd() { #定时任务工具
|
croncmd() { #定时任务工具
|
||||||
if [ -w "$crondir" ] && [ -n "$USER" ];then
|
if [ -n "$(crontab -h 2>&1 | grep '\-l')" ]; then
|
||||||
|
crontab "$1"
|
||||||
|
elif [ -w "$crondir" ] && [ -n "$USER" ];then
|
||||||
[ "$1" = "-l" ] && cat "$crondir"/"$USER" 2>/dev/null
|
[ "$1" = "-l" ] && cat "$crondir"/"$USER" 2>/dev/null
|
||||||
[ -f "$1" ] && cat "$1" >"$crondir"/"$USER"
|
[ -f "$1" ] && cat "$1" >"$crondir"/"$USER"
|
||||||
elif [ -n "$(crontab -h 2>&1 | grep '\-l')" ]; then
|
killall -HUP crond 2>/dev/null
|
||||||
crontab "$1"
|
|
||||||
else
|
else
|
||||||
echo "找不到可用的crond或者crontab应用!No available crond or crontab application can be found!"
|
echo "找不到可用的crond或者crontab应用!No available crond or crontab application can be found!"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user