~修复crontab报错

~部分细节调整
This commit is contained in:
juewuy
2026-01-01 15:38:26 +08:00
parent 4f31373c5f
commit ecca342893
3 changed files with 7 additions and 5 deletions

View File

@@ -6,9 +6,11 @@ crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}')"
tmpcron="$TMPDIR"/cron_tmp
croncmd() { #定时任务工具
if [ -w "$crondir" ]; then
[ "$1" = "-l" ] && cat "$crondir"/"$USER"
if [ -w "$crondir" ] && [ -n "$USER" ];then
[ "$1" = "-l" ] && cat "$crondir"/"$USER" 2>/dev/null
[ -f "$1" ] && cat "$1" >"$crondir"/"$USER"
elif [ -n "$(crontab -h 2>&1 | grep '\-l')" ]; then
crontab "$1"
else
echo "找不到可用的crond或者crontab应用No available crond or crontab application can be found!"
fi