shell 脚本编辑 crontab 任务

#!/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}

猜你喜欢

转载自blog.csdn.net/u013393704/article/details/80635021