# 注释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 -l > ${WORK_DIR}/cron_binary
sed -i 's%\(.*/home/xyz/xyz.sh\)%#\1%' ${WORK_DIR}/cron_binary
crontab ${WORK_DIR}/cron_binary
sed -i 's%\(.*/\)%#\1%' /var/spool/cron/ec2-user
# 恢复crontab
crontab -l > ${WORK_DIR}/cron_binary
sed -i 's%\(^##*\)\(.*/home/xyz/xyz.sh\)%\2%' ${WORK_DIR}/cron_binary
crontab ${WORK_DIR}/cron_binary
crontab -l > ${WORK_DIR}/cron_binary
sed -i 's%\(^##*\)\(.*/home/xyz/xyz.sh\)%\2%' ${WORK_DIR}/cron_binary
crontab ${WORK_DIR}/cron_binary
sed -i 's%\(^##*\)\(.*/\)%\2%' /var/spool/cron/ec2-user
用你的任务名替换上面的/home/xyz/xyz.sh, 然后写成脚本加到crontab中定时执行, 就OK