- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: attaching time stamp on out put file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2008 03:17 AM
тАО11-07-2008 03:17 AM
I am trying to ececute one script from crontab. I want to get the out in one file.
But i want file should have date and time as well.
My crontan setting is like:
00,15,30,45 * * * * /usr/sym/syst/menus/yqclear.scr 1>/tmp/log 2>&1
I want to attach date and time as well with log file.
like
00,15,30,45 * * * * /usr/sym/syst/menus/yqclear.scr 1>/tmp/log_`date +%Y%m%d%H%M` 2>&1
But it is not working. I am getting file :
log_200811071116.
Can any one please help me how to do this?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2008 03:39 AM
тАО11-07-2008 03:39 AM
Re: attaching time stamp on out put file
Do you want the date and time should be inside the output file or in the output file name?
how should your output file look like?
Ganesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2008 03:40 AM
тАО11-07-2008 03:40 AM
Re: attaching time stamp on out put file
... DATE=$(date +%Y%m%d%H%M); (echo $DATE; \
/usr/sym/syst/menus/yqclear.scr) > tmp/log_$DATE 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2008 03:43 AM
тАО11-07-2008 03:43 AM
Re: attaching time stamp on out put file
... DATE=$(date +\%Y\%m\%d\%H\%M); (echo $DATE; \
/usr/sym/syst/menus/yqclear.scr) > tmp/log_$DATE 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2008 03:47 AM
тАО11-07-2008 03:47 AM
Re: attaching time stamp on out put file
text as well as real date formatting
directives:
bash$ date +/tmp/log_%Y%m%d%H%M
/tmp/log_200811070540
bash$ echo fred > ` date +/tmp/log_%Y%m%d%H%M `
bash$ ls -l /tmp/log_*
-rw-r----- 1 SMS 40 5 Nov 7 05:45 /tmp/log_200811070545
bash$ cat /tmp/log_200811070545
fred
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2008 04:09 AM
тАО11-07-2008 04:09 AM
Re: attaching time stamp on out put file
I want date and time be as a part of file name.
it is giving proper file name but out is nothing but date value.
Here i am executing clear.scr which contains code:
echo " Welcome ".
My log file should show this message when i open the file(log_200811071206). But it shows value as 200811071206.
06 12 * * 1-5 DATE=$(date +\%Y\%m\%d\%H\%M); (echo $DATE; \ /usr/symology/cle
ar.scr) > /usr/symology/log_$DATE
Please suggest..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2008 04:27 AM
тАО11-07-2008 04:27 AM
Re: attaching time stamp on out put file
# echo "welcome" 1>/tmp/log_`date +%Y%m%d%H%M` 2>&1
# ll /tmp/log*
-rw-rw-rw- 1 root sys 8 Nov 7 06:25 /tmp/log_200811070625
# more /tmp/log_200811070625
welcome
#
Ganesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2008 06:08 AM
тАО11-07-2008 06:08 AM
Re: attaching time stamp on out put file
Well, that IS the date and time from your command.
You did:
/tmp/log_`date +%Y%m%d%H%M`
So, from the 'date' command you get:
%Y = 2008 (the year)
%m = 11 (the month)
%d = 07 (the day)
%H = 12 (The hour)
%M = 06 (The minutes)
I'm not sure what else you want. Your explanations are not very clear to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2008 06:08 AM
тАО11-07-2008 06:08 AM
Re: attaching time stamp on out put file
Once you get the log filename, you have to put what you want into the file.
You can adjust that echo I suggested, or remove it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2008 07:06 AM
тАО11-07-2008 07:06 AM
SolutionWhat Dennis has suggested is the solution for you.
00,15,30,45 * * * * /usr/sym/syst/menus/yqclear.scr 1>/tmp/log_$(date "+\%Y\%m\%d\%H\%M") 2>&1
will do in one line.
You could have looked at /var/adm/cron/log file - for what cron is actually executing (means what it understands as the command to be executed).
This would have given you a clue where exactly you are going wrong.
Regards,
Ninad