问题
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:
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.
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.
Use a shell based solution, like datecalc. If your
$TIMEDELTAis 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.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