AIX equivalent for 'date --date'

不问归期 提交于 2019-12-10 22:49:31

问题


I frequently use the date command with the --date option on linux servers like

date --date="3min"

However the -d/--date option don't seems available on AIX server : https://www.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.cmds2/date.htm

Is it possible, and how can we get the same result as the following command:

date --utc --date "now $TIMEDELTA" +"%Y%m%d-%H")`

in an AIX environment ?

I don't have, and can't have, any root access to the server.


回答1:


A few options come to mind:

  1. Download GNU date to your home directory and compile there. Pros: you get the full power of GNU date, with Cons: requires compilation and management, not immediately available to other users or machines.

  2. Emulate the behavior using PERL, TCL, PHP, MySQL or any other high level language. Pros: you get a lot of power, without having to install anything, but with Cons: you have to know the language and you're dependent on it being there.

  3. Use a shell based solution, like datecalc. If your $TIMEDELTA is in days, you could use: datecalc $(date +'%Y %m %d') + $TIMEDELTA. Pros: no external tools needed, with Cons: only works on day level granularity and isn't immediately available to other users or machines.

  4. Purpose build your own little program using strptime, getdate, or other C built-ins. Pros: decidedly solves your problem, with Cons: not immediately available to other users or machines, you might have to learn C, not forward flexible.



来源:https://stackoverflow.com/questions/37029699/aix-equivalent-for-date-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!