2

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.

codeforester
  • 39,467
  • 16
  • 112
  • 140
Arthur Saint-Genis
  • 167
  • 1
  • 2
  • 12
  • 1
    I guess this is the same problem that Solaris faces. You need to use Perl or another tool to process the data. See [equivalent date from GNU to solaris](http://stackoverflow.com/q/17815327/1983854). – fedorqui May 04 '16 at 13:48
  • The [Super User](http://superuser.com/) site is the better place to ask. – Hristo Iliev May 04 '16 at 13:50

1 Answers1

2

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.

bishop
  • 37,830
  • 11
  • 104
  • 139