Error Logging

From Server Knowledge Base
Jump to navigationJump to search
#!/bin/bash

DATE=`date +%Y%m%d`
TIME=`date +%H%M%S`
HOUR=`date +%H`
mkdir -p /root/process/$DATE/$HOUR/
echo "Process List" > /root/process/$DATE/$HOUR/log.$TIME
ps aux >> /root/process/$DATE/$HOUR/log.$TIME
echo "===" >> /root/process/$DATE/$HOUR/log.$TIME
echo "netstat" >> /root/process/$DATE/$HOUR/log.$TIME
netstat -anp >> /root/process/$DATE/$HOUR/log.$TIME