Wednesday, December 23, 2015

Create a file using timestamp

#########
TCL:
#########

#!/bin/sh
# \
exec $AUTOTEST/bin/tclsh "$0" ${1+"$@"}

set GA(timestamp) [exec date +%Y%m%d%H%M%S]
file mkdir $GA(tftp_path)/log_$GA(timestamp)
exec /bin/sh -c "chmod 777 $GA(tftp_path)/log_$GA(timestamp)"

########
Shell script
########

#!/bin/bash
c=1
while [ $c -le 5 ]
do
  top -n 1 | grep -e smd -e linux_iosd -e fman >> /flash/top_$(date +%Y%m%d%H%M%S).log
  free -c 1 >> /flash/free_$(date +%Y%m%d%H%M%S).log
  sleep 15m
done

## Above script will run forever and will provide the output of "top" and "free" commands every 15 minutes ##