Monday, August 3, 2015

Create directory with current date

[bgl-ads-843:/auto/tftp-blr-users1/srikragh]>ls -lrt /auto/tftp-sanity-testbed-infra/wireless_accounting_logs/
total 12
drwxrwxrwx 2 srikragh eng 4096 Jul 24 22:26 20150723/
drwxrwxrwx 2 srikragh eng 4096 Aug  1 01:06 run2/
drwxrwxrwx 2 srikragh eng 4096 Aug  2 15:13 run1/
[bgl-ads-843:/auto/tftp-blr-users1/srikragh]>
[bgl-ads-843:/auto/tftp-blr-users1/srikragh]>
[bgl-ads-843:/auto/tftp-blr-users1/srikragh]>mkdir "/auto/tftp-sanity-testbed-infra/wireless_accounting_logs/`date +%Y%m%d`"
[bgl-ads-843:/auto/tftp-blr-users1/srikragh]>
[bgl-ads-843:/auto/tftp-blr-users1/srikragh]>
[bgl-ads-843:/auto/tftp-blr-users1/srikragh]>ls -lrt /auto/tftp-sanity-testbed-infra/wireless_accounting_logs/            total 16
drwxrwxrwx 2 srikragh eng 4096 Jul 24 22:26 20150723/
drwxrwxrwx 2 srikragh eng 4096 Aug  1 01:06 run2/
drwxrwxrwx 2 srikragh eng 4096 Aug  2 15:13 run1/
drwxr-xr-x 2 srikragh eng 4096 Aug  3 15:12 20150803/
[bgl-ads-843:/auto/tftp-blr-users1/srikragh]>
[bgl-ads-843:/auto/tftp-blr-users1/srikragh]>

Below is TCL code for the same:

        set GA(tftp_path) /auto/tftp-blr-users1/wireless_accounting
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)"

Sample output

drwxrwxrwx 2 srikragh  eng       4096 Aug  3 23:01 log_20150803101713/
drwxrwxr-x 2 srikragh  eng       4096 Aug  3 23:04 log_20150803103459/
drwxrwxrwx 2 srikragh  eng       4096 Aug  3 23:20 log_20150803104920/


No comments:

Post a Comment