touch

Updates the access and modification times of the file specified by the URI to the current time.

If the file doesn’t exist, then a zero-length file is created at URI with current time as the timestamp of that URI.

The timestamp format is as follows: yyyyMMddHHmmss. Where:

  • yyyy — four digit year (e.g. 2018);

  • MM — two digit month (e.g. 08 for August);

  • dd — two digit day (e.g. 25);

  • HH — two digit hour (e.g. 12);

  • mm — two digit minute (e.g. 30);

  • ss — two digit second (e.g. 00).

Thus, the value 20180825:123000 represents August 25th 2018, 12:30:00 pm.

Returns 0 on success and -1 on error.

The usage is as follows:

$ hadoop fs -touch [-a] [-m] [-t TIMESTAMP] [-c] URI [URI ...]
Arguments

-a

Changes only the access time

-m

Changes only the modification time

-t

Specifies a timestamp (in format yyyyMMdd:HHmmss) instead of the current time

-c

Doesn’t create file if it doesn’t exist

Example:

$ hadoop fs -touch -m -t 20180809:230000 pathname
$ hadoop fs -touch -t 20180809:230000 pathname
$ hadoop fs -touch -a pathname
Found a mistake? Seleсt text and press Ctrl+Enter to report it