# 注释crontab任务
crontab -l > ${WORK_DIR}/cron_binary
sed -i ‘s%\(.*/home/xyz/xyz.sh\)%#\1%‘ ${WORK_DIR}/cron_binary
crontab ${WORK_DIR}/cron_binary
# 恢复crontab
crontab -l > ${WORK_DIR}/cron_binary
sed -i ‘s%\(^##*\)\(.*/home/xyz/xyz.sh\)%\2%‘ ${WORK_DIR}/cron_binary
crontab ${WORK_DIR}/cron_binary
用你的任务名替换上面的/home/xyz/xyz.sh, 然后写成脚本加到crontab中定时执行, 就OK
时间: 2024-10-03 20:49:53