vim ~/cronlog.sh --- #!/bin/sh logfile="/root/cron.log" touch /root/cron.log chmod 0777 /root/cron.log buf="" while read f; do line=$f if [ -n "$line" ] && [ `echo "$line" | egrep "^ *([0-9]|\*)" | wc -l` -gt 0 ] ;then line="${line};echo \"${line} - \`date\`\" >> ${logfile}" fi buf=`cat <<EOM $buf $line EOM` done echo "$buf" --- chmod +x ~/cronlog.sh cat /etc/crontab | ~/cronlog.sh 1> /etc/crontab.debug mv /etc/crontab{,.bak}; cp /etc/crontab{.debug,}
cp /etc/crontab{,.debug}