在AIX平台如何取n天前/n天后的日期 How To Get N Day Ago/After On Aix

作者:aland|除非注明文章均为原创,转载时请以超链接形式标明文章出处和作者信息及本声明
本文标题:在AIX平台如何取n天前/n天后的日期 How To Get N Day Ago/After On Aix 链接 http://www.alandcheung.com/?p=215

今日给某个客户做一个脚本,需要取系统日期前n天的值,由于在AIX的机器上,所以没有办法如在Linux上一样通过下面的脚本来取当前日期前后n天:

export date1= $(date -d "$date -n day" +%Y%m%d)

因此只能曲线救国,使用别的方法了。这里使用了先在oracle中进行date取值并将结果spool,再通过awk命令将 文本中取到的日志赋予变量的方法来实现。方法如下:

 

splus ‘/ AS sysdba’<<EOF
 
SET heading off
 
SET term off
 
spool /u02/backup/day2.txt
 
SELECT to_char(sysdate – 2, ‘YYYYMMDD’) day2 FROM dual;
 
spool off
 
exit
 
EOF

上面的脚本实现将需要的日期计算通过Oracle自带函数来实现,并将结果输出到/u02/backup/day2.txt

 

export day2= `awk 'NR==1' /u02/backup/day2.txt`

 

通过awk,取/u02/backup/day2.txt,NR取第一行,并赋值给day2

About aland

I am currently working as a Senior Consultant with Enmo Tech in Beijing, China. Oracle Certified Professional Oracle 10g and 10g OCM with about 4 years of Oracle experience. Experiece on Grid Control, High Availability Solutions (Dataguard and RAC), Performance and SQL Tuning, Oracle 8i, 9i, 10g, 11g, Hybrid and OLTP Systems. Email: aland.cheung1@gmail.com Gtalk: aland.cheung1@gmail.com

Posted on January 4, 2012, in Linux, Oracle and tagged , . Bookmark the permalink. 33 Comments.

  1. Very good article, thanks for this article. if you need information about technology, Visit to my site

  2. My brother recommended I may like this blog. He used to be entirely right. This submit truly made my day. You cann’t believe simply how a lot time I had spent for this info! Thanks!

  3. Lol I found meridia’s beacon in talking stone? camp lol??? I didn’t even have the quest to even find it

  4. Hello, i read your blog occasionally and i own a similar one and i was just curious if you get a lot of spam feedback? If so how do you prevent it, any plugin or anything you can suggest? I get so much lately it’s driving me insane so any support is very much appreciated.

  5. The next time I read a blog, I hope that it doesnt disappoint me as significantly as this one. I mean, I know it was my option to read, but I essentially thought youd have some thing intriguing to say. All I hear is often a bunch of whining about something that you could fix for those who werent too busy looking for attention.

  6. Wow, what a video it is! In fact pleasant quality video, the lesson given in this video is truly informative.

  7. Oh my goodness! a fantastic post dude. Thanks Nevertheless My business is experiencing concern with ur rss . Don’t know why Not able to sign up for it. Possibly there is any person obtaining identical rss difficulty? Anyone who knows kindly respond. Thnkx

  8. I have to thank you for the efforts you have put in writing this website. I am hoping to check out the same high-grade blog posts from you in the future as well. In truth, your creative writing abilities has inspired me to get my very own blog now

  9. Lovely just what I was seeking.

  10. vey good video, you are a pro , thanks

  11. Very good article, thanks for this article. if you need information about technology, Visit to my site

  12. Hello there! Do you know if they make any plugins to safeguard against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any tips?

  13. Hmm is anyone else encountering problems with the pictures on this blog loading? I’m trying to figure out if its a problem on my end or if it’s the blog. Any responses would be greatly appreciated.

  14. Wow, incredible weblog format! How lengthy have you ever been blogging for? you make blogging look easy. The total look of your web site is fantastic, let alone the content!

  15. Hmm it looks like your site ate my first comment (it was super long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to the whole thing. Do you have any helpful hints for inexperienced blog writers? I’d certainly appreciate it.

  16. Pretty! This has been a really wonderful post. Many thanks for supplying these details.

  17. Wow, what a video it is! Really good quality video, the lesson given in this video is truly informative.

  18. I really appreciate this post. I have been looking all over for this! Thank goodness I found it on Bing. You have made my day! Thx again

  19. These all YouTube gaming movies are in fact in pleasant quality, I watched out all these along by means of my friends.

  20. Thanks so much for providing individuals with a very terrific opportunity to discover important secrets from this blog. It is often so useful and as well , packed with a good time for me personally and my office fellow workers to search the blog nearly three times in a week to learn the newest guidance you will have. And definitely, I’m also always contented with your stunning pointers served by you. Certain 4 facts in this posting are surely the very best I’ve had.

  21. Its such as you learn my mind! You seem to grasp so much approximately this, like you wrote the e book in it or something. I believe that you simply can do with a few p.c. to drive the message house a bit, however instead of that, this is excellent blog. An excellent read. I’ll certainly be back.

  22. Hi, I do think this is a great site. I stumbledupon it ;) I’m going to return yet again since I bookmarked it. Money and freedom is the greatest way to change, may you be rich and continue to help others.

  23. While searching at the card, it is essential to research each element properly. The color of the candle is not very important, but violet or blue candles enhance your psychic skills.

  24. I’m amazed, I have to admit. Seldom do I encounter a blog that’s both equally educative and amusing, and without a doubt, you have hit the nail on the head. The issue is something not enough folks are speaking intelligently about. I am very happy I came across this during my hunt for something regarding this.

  25. You made some good points there. I checked on the net for additional information about the issue and found most people will go along with your views on this website.

  26. When I originally commented I seem to have clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I recieve four emails with the exact same comment. Is there a means you can remove me from that service? Thank you!

  27. Someone necessarily lend a hand to make seriously articles I would state. That is the very first time I frequented your website page and to this point? I surprised with the analysis you made to make this particular publish incredible. Excellent activity!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>