TMP_FILE=$HOME/temp.txt
LOG_FILE=/dev/log/mylog/deploy.log
crontab -l >> $TMP_FILE
TMP_ST=$?
TMP_F=`cat $TMP_FILE | wc -l `
if [ $TMP_F = 0 ]; then
echo "30 0 * * * sh /home/ap/web/bin/dist/nginx_log_cut_clean.sh" >> $TMP_FILE
[ $? != 0 ] && echo "add crontab to $TMP_FILE faild and exit " >> $LOG_FILE && exit 1
else
if [ $TMP_ST = 0 ]; then
echo "30 0 * * * sh /home/ap/web/bin/dist/nginx_log_cut_clean.sh" >> $TMP_FILE
[ $? != 0 ] && echo "add crontab to $TMP_FILE faild and exit " >> $LOG_FILE && exit 1
else
echo "export crontab faild and exit 1 " >> $LOG_FILE && exit 1
fi
fi
crontab $TMP_FILE
rm -rf $TMP_FILE
crontab -l | grep nginx_log_cut_clean.sh
exit $?