• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

faketime Command Examples in Linux

by Deepika

“faketime” is a command-line tool in Linux-based systems that allows a user to run a command with a fake system time. This means that the command will see a different system time than the actual one, allowing the user to test how the command behaves under different time conditions.

faketime works by intercepting calls to the system time functions and replacing the actual time with a fake time. The fake time can be specified in various ways, such as a specific date and time, or a relative offset from the current time. For example, you can use faketime to test how a program behaves when the system time is set to a specific date in the past or future, or to test how a program handles leap years or daylight saving time changes.

It is important to note that faketime does not change the system time, it only changes the time seen by the command it runs. This means that other programs and processes running on the system will still see the actual system time. Also, faketime does not affect the hardware clock or the system time in any way. It only affect the time returned by time() and similar functions.

faketime Command Examples

1. Fake the time to this evening, before printing the result of `date`:

faketime 'today 23:30' date

2. Open a new `bash` shell, which uses yesterday as the current date:

faketime 'yesterday' bash

3. Simulate how a program would act next Friday night:

faketime 'next Friday 1 am' path/to/program

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to disable firewalld and and switch to iptables in CentOS / RHEL 7
  2. jstest: command not found
  3. How to run a cron job on specific days of the week
  4. chgrp: command not found
  5. How to disable Ctrl+Alt+Del causing system reboot in CentOS/RHEL 6
  6. How to Extend allowed number of loopback devices
  7. How to install CentOS / RHEL 7 on RAID Partition
  8. CentOS / RHEL 7 : Lock User Account After N Number of Incorrect Login Attempts
  9. RHEL 7 – RHCSA Notes – System documentation including man, info, and files in /usr/share/doc
  10. e2image Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • fprintd-delete Command Examples in Linux
  • fprintd-delete: command not found
  • foreman: command not found
  • foreman Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright