#!/bin/bash
SCHED_FILE="/home/liuyg/study/crontab_sched_file"
# check the sched file exist
if [ ! -f "${SCHED_FILE}" ]; then
touch ${SCHED_FILE}
fi
# stop cron
service cron stop
# replace cron file
echo " * * * * * date +'\%F \%T' >> /home/liuyg/study/test" > ${SCHED_FILE}
echo " * * * * * echo 'hello world' >> /home/liuyg/study/test" >> ${SCHED_FILE}
# start cron
service cron start
# crontab
crontab ${SCHED_FILE}
shell 脚本编辑 crontab 任务
最新推荐文章于 2025-03-25 14:30:58 发布