Developer Tips
------------ create cscope and tags to source code --------------
Create CTAGS, CREATE FILE LIST [cscope.files], start cscope where the cscope.file exist.
cscope steps - ctags -R . ; find . -name *.[CchH] > cscope.files ; cscope # ready to start using cscope.
Using Ctrl+] Ctril+T for moving forward/ backwards.
----------------------------------------------------------
Setting up messages file log rotation on linux
1. # su - $ change to root account
2. # go to /etc/logrotate.d
# delete the line (/var/log/messages) from file syslog
sed "/message/d" /etc/logrotate.d/syslog > /tmp/tmpsyslog && mv /tmp/tmpsyslog /etc/logrotate.d/syslog OR
grep -v "message" /etc/logrotate.d/syslog > /tmp/tmpsyslog && mv /tmp/tmpsyslog /etc/logrotate.d/syslog
3. #create new file and add below content to limit the file rotate on 20M file size or weekly once which is satisfied
cat <<EOF > /etc/logrotate.d/messageslog
/var/log/messages
{
weekly
rotate 13
size 20M
missingok
dateext
dateformat -%Y%m%d-%s
notifempty
}
EOF
4. #Make entry to file /etc/cron.d/0hourly - run the logrotate for messages every 4 hrs at 2 min time
02 */4 * * * root logrotate /etc/logrotate.d/messageslog
OR
add above entry to crontab using command
crontab -e
to run the script at 5th min of each hour
05 * * * * root logrotate /etc/logrotate.d/messageslog
For running every few seconds (running lesser than 1 min duration) As the cron allows the granularity set upto 1 min only, below is the example to run the log rotation every 30 sec (2 times) or 15 secs (3 times)
* * * * * root logrotate /etc/logrotate.d/messageslog && sleep 30; logrotate /etc/logrotate.d/messageslog
* * * * * root for i in 0 1 2; do logrotate /etc/logrotate.d/messageslog & sleep 15; done;
-----------------------------
# script to fill up the messages file under /var/log folder
create a file with 777 permissions in /tmp
touch /tmp/nonstop.txt
# execute logger command to start dumping content of this file into the /var/log/messages file
logger -f /tmp/nonstop.txt
# run the script to write into /tmp/nonstop.txt file
test it by executing - sudo echo "Hello Test" > /tmp/nonstop.txt
================notstop.sh START ================
#!/bin/bash
counter=0
while true
do
sudo echo "$counter - testing non stop logs to messages file" > /tmp/nonstop.txt
counter=$(( counter + 1 ))
sleep 1
# -n option, omits the new line after echo
echo -n '.'
done
================notstop.sh END================
linux kernel source
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/net/ipv4/tcp_input.c?h=linux-4.0.y
file - /net/ipv4/tcp_input.c
RFC - https://tools.ietf.org/html/rfc5827#section-3
https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
-----------------------------
Comments