Skip to content
Advertisement

Linux Date Function forward/backward time

Is there an option of date function?

How do I get LOAD_TEST_START to be 2 minutes forward?

How do I get LOAD_TEST_END to be 2 minutes back?

LOAD_TEST_START=$(date -u +%FT%TZ)
LOAD_TEST_END=$(date -u +%FT%TZ)

Advertisement

Answer

This answer helped me and works on the linux-version of date.

LOAD_TEST_START=$(date +%FT%TZ -d "2 minutes ago")
LOAD_TEST_END=$(date +%FT%TZ -d "2 minutes")

On macos/FreeBSD one can use

LOAD_TEST_START=$(date -v+2M +%FT%TZ)
LOAD_TEST_END=$(date -v-2M +%FT%TZ)
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement