Determining Amazon EC2 instance creation date/time

后端 未结 5 622
灰色年华
灰色年华 2021-01-02 02:32

Is it possible to determine (via boto) when a particular EC2 instance was created?

http://boto.readthedocs.org/en/latest/ref/ec2.html doesn\'t seem to be giving any

5条回答
  •  暖寄归人
    2021-01-02 02:52

    if you want to calculate the current uptime based on launchtime of an EC2 instance, one can try this:

    import datetime
    lt_datetime = datetime.datetime.strptime(i.launch_time, '%Y-%m-%dT%H:%M:%S')
    lt_delta = datetime.datetime.utcnow() - lt_datetime
    uptime = str(lt_delta)
    

提交回复
热议问题