date format linux
I was working with an Automated Scripting which will generate reports and mail the User.
I want the script to run at every day Morning by 8:00 AM.
I wanted the log file to be created and the name should be the date time when the script started to run.
Say for example, I run the script today ( 30 Dec 2014, 5:50 PM). Hence I
want the name of the log file as
30_12_14_17_50_00.log
I chosed the script as
Where,
%d -> Date
%m -> Month
%y -> Year
%T -> Current Time in 24 Hour Format
tr is a command utility to find and replaces string / character inline.
tr ":" "_" means, replace ":" with "_".
I got the documentation of the date command here, which was helpful.
http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/
I was working with an Automated Scripting which will generate reports and mail the User.
I want the script to run at every day Morning by 8:00 AM.
I wanted the log file to be created and the name should be the date time when the script started to run.
Say for example, I run the script today ( 30 Dec 2014, 5:50 PM). Hence I
want the name of the log file as
30_12_14_17_50_00.log
I chosed the script as
date +"%d_%m_%y_%T" | tr ":" "_"
Where,
%d -> Date
%m -> Month
%y -> Year
%T -> Current Time in 24 Hour Format
tr is a command utility to find and replaces string / character inline.
tr ":" "_" means, replace ":" with "_".
I got the documentation of the date command here, which was helpful.
http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/
No comments:
Post a Comment