🤖
Guides
  • Introduction
  • Beginners
    • Getting Started
  • Guides
    • SQLi Walkthrough
    • My First BoF
    • OSCP Buffer Overflow Guide (Windows)
    • Parrot OS customisation
    • Terminal Customisation
    • Video Guides
  • Cheat Sheets
    • Reverse Shells
    • Tunnelling, Pivoting and Proxies
    • SQL Injection
      • WAF Bypass
      • SQLMap
      • DBMS Cheatsheets
        • MSSQL
        • MySQL
        • Oracle
        • SQLite
        • PostgreSQL
      • References
    • Bash Cheat Sheets
      • Terminal
      • Find
      • Grep
      • Sed
      • Awk
      • Xargs
      • System
      • Download
      • Networking
      • Hardware
      • Variable
      • Math
      • Data Manipulation
      • Random
      • Time
      • Condition and Loop
      • Other
    • OSINT
    • Ping Sweeps
  • Methodologies
    • VOIP Checklist
    • OWASP v4 Checklist
    • External Inf
    • Internal Infrastructure
  • Linux
    • Checklist - Linux Priv Esc
  • Windows
    • Checklist - Windows Priv Esc
  • Things to do/look at
Powered by GitBook
On this page
  • Time
  • Find out the time require for executing a command
  • Wait for some time (e.g 10s)
  • Print date with formatting
  • wait for random duration (e.g. sleep 1-5 second, like adding a jitter)
  • Log out your account after a certain period of time (e.g 10 seconds)
  • Set how long you want to run a command
  • Set when you want to run a command (e.g 1 min from now)

Was this helpful?

  1. Cheat Sheets
  2. Bash Cheat Sheets

Time

Time

Find out the time require for executing a command

time echo hi

Wait for some time (e.g 10s)

sleep 10

Print date with formatting

date +%F
# 2020-07-19

# or
date +'%d-%b-%Y-%H:%M:%S'
# 10-Apr-2020-21:54:40

# Returns the current time with nanoseconds.
date +"%T.%N"
# 11:42:18.664217000  

# Get the seconds since epoch (Jan 1 1970) for a given date (e.g Mar 16 2021)
date -d "Mar 16 2021" +%s
# 1615852800
# or
date -d "Tue Mar 16 00:00:00 UTC 2021"  +%s
# 1615852800  

# Convert the number of seconds since epoch back to date
date --date @1615852800
# Tue Mar 16 00:00:00 UTC 2021

wait for random duration (e.g. sleep 1-5 second, like adding a jitter)

sleep $[ ( $RANDOM % 5 ) + 1 ]

Log out your account after a certain period of time (e.g 10 seconds)

TMOUT=10
#once you set this variable, logout timer start running!

Set how long you want to run a command

#This will run the command 'sleep 10' for only 1 second.
timeout 1 sleep 10

Set when you want to run a command (e.g 1 min from now)

at now + 1min  #time-units can be minutes, hours, days, or weeks
warning: commands will be executed using /bin/sh
at> echo hihigithub >~/itworks
at> <EOT>   # press Ctrl + D to exit
job 1 at Wed Apr 18 11:16:00 2018
PreviousRandomNextCondition and Loop

Last updated 4 years ago

Was this helpful?