- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How get a date in file a day after?
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
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
тАО08-23-2006 11:14 PM
тАО08-23-2006 11:14 PM
How get a date in file a day after?
I am trying to write some script which will sort some data using awk. In that script I need a date for every day, and it should be changed for that day.
I tried to acomplish this using
echo '+%Y%m%d'>date
d='cat date'
This script should write some data on day basis and it should do it automatically.
I other words when I run this script now, inside it I need come mechanism to get a date for yesterday. I will make it to run every day at 03:00 AM for previous day, so it is necessary to be able to get a date for that day, and it should be a variable.
I think this is probably messy, but every hint related to this is welcomed.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2006 11:56 PM
тАО08-23-2006 11:56 PM
Re: How get a date in file a day after?
d=`date +%Y%m%d`
and added to A_$d.txt to get a filename for day in form A_20060824.txt, but I cannot use this because I need to run this script after 00:00 for previous day and above statement related to date is not valid in that case.
So is there any way to add date for yesterday in script which I run today.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2006 01:58 AM
тАО08-24-2006 01:58 AM
Re: How get a date in file a day after?
date --date yesterday +%Y%m%d
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2006 05:34 PM
тАО08-24-2006 05:34 PM
Re: How get a date in file a day after?
your solution works on my linux machines, but in case of Siemens Reliant UNIX 5.43 it does not work.
It is interesting that I need this the most on this Relinat Unix machine. I read man page for date on Relinat Unix machine, but there is not any hint how set time for this purpose.
Thanks again.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 12:08 AM
тАО08-25-2006 12:08 AM
Re: How get a date in file a day after?
On my systems, I have this cronjob set up:
59 23 * * * /usr/bin/date > /tmp/yester # Yesterday's date to /tmp/yester
Then anytime I need yesterday's date, I just reference /tmp/yester.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 01:05 AM
тАО08-25-2006 01:05 AM
Re: How get a date in file a day after?
what if you need this during last minute of the day,... perhaps you could set this for last second of the day but then the risk it run on next day gets high!
Perhaps it is posible to do a test like
ls -l /tmp/yester and check this with the containt of /tmp/yester to see is this did run on the day before or passed the day line !
just less then 2 cent worth rumbling
Jean-Pierre Huc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 03:48 AM
тАО08-25-2006 03:48 AM
Re: How get a date in file a day after?
Of course, you are right: care must be taken with this approach. However, it really is quite reliable as long as you keep those caveats in mind. And it can be made even safer by verifying the timestamp, as you suggested.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 04:50 AM
тАО08-25-2006 04:50 AM
Re: How get a date in file a day after?
Date::Manip
Have a look at man Date::Manip lots of examples there.
Hope this is usable for you.
Jean-Pierre Huc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 07:40 AM
тАО08-25-2006 07:40 AM
Re: How get a date in file a day after?
d=`TZ=MET+24 date +%Y%m%d`
and I use d as variable.
For two days ago
d=`TZ=MET+48 date +%Y%m%d`
and so on.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 07:44 AM
тАО08-25-2006 07:44 AM
Re: How get a date in file a day after?
I think forums like this one are very helpfull for people who works with different technologies and all of us have to support places like this.
Thanks