免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1880 | 回复: 8
打印 上一主题 下一主题

请教在solaris中如何取前一天的系统时间? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-01-10 12:33 |只看该作者 |倒序浏览
各位大哥,请教一下
在linux 中我可以用$ DATE=$(date +%Y%m%d --date '1 days ago')可取得前一天的系统时间,但在solaris中却不行,在solaris中要用什么命令才能取得前一天的系统时间?谢谢先。

论坛徽章:
0
2 [报告]
发表于 2005-01-10 15:13 |只看该作者

请教在solaris中如何取前一天的系统时间?

play with env TZ
yesterday=$(export TZ=$TZ+16; date +%Y%m%d)

论坛徽章:
0
3 [报告]
发表于 2005-01-10 15:29 |只看该作者

请教在solaris中如何取前一天的系统时间?

没人知道吗?我顶起来。
刚写完就看到有朋友回复,不好意思。谢谢楼上的朋友,我先试试。
# play with env TZ
play: not found

大哥,play with env TZ是什么意思?好像不行呀。?

论坛徽章:
0
4 [报告]
发表于 2005-01-10 16:31 |只看该作者

请教在solaris中如何取前一天的系统时间?

yesterday=$(export TZ=$TZ+16; date +%Y%m%d);echo $yesterday

论坛徽章:
0
5 [报告]
发表于 2005-01-10 16:36 |只看该作者

请教在solaris中如何取前一天的系统时间?

# yesterday=$(export TZ=$TZ+16; date +%Y%m%d);echo $yesterday
syntax error: `yesterday=$' unexpected
大哥,不行呀。
这个错误是什么意思呀?

论坛徽章:
0
6 [报告]
发表于 2005-01-10 16:43 |只看该作者

请教在solaris中如何取前一天的系统时间?

yesterday=`export TZ=$TZ+16; date +%Y%m%d`;echo $yesterday

PS : TZ means timezone ,   echo $TZ for you current TZ setting , the idea here is to fool the shell with a different Timezone instead of current one  ,  different timezone will result to different time .

论坛徽章:
0
7 [报告]
发表于 2005-01-10 16:52 |只看该作者

请教在solaris中如何取前一天的系统时间?

原帖由 "dradhzn" 发表:
yesterday=`export TZ=$TZ+16; date +%Y%m%d`;echo $yesterday

PS : TZ means timezone ,   echo $TZ for you current TZ setting , the idea here is to fool the shell with a different Timezone instead of ..........


大哥,还是有错。
# yesterday=`export TZ=$TZ+16; date +%Y%m%d`;echo $yesterday
TZ=PRC+16: is not an identifier
我用env看到TZ=PRC

# env
EDITOR=/usr/bin/vi
HOME=/
HZ=100
LANG=zh.GBK
LOGNAME=root
MAIL=/var/mail/root
PATH=/usr/sbin:/usr/bin
SHELL=/sbin/sh
TERM=vt100
TZ=PRC
不知怎么回事,需要改吗?谢谢!!!

我在另一台solaris上可以正确输出,但这台不行,是不是配置文件不全的问题。
我看这两台机器上的env不一样。我很想知道原因?谢谢!

论坛徽章:
0
8 [报告]
发表于 2005-01-10 19:13 |只看该作者

请教在solaris中如何取前一天的系统时间?

use ksh ,type
#ksh         
then
# yesterday=`export TZ=$TZ+16; date +%Y%m%d`;echo $yesterday

if sh
yesterday=`TZ=$TZ+16; date +%Y%m%d`;echo $yesterday

论坛徽章:
0
9 [报告]
发表于 2005-01-11 23:32 |只看该作者

请教在solaris中如何取前一天的系统时间?

谢谢这位朋友,搞定了,谢谢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP