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 ...]
-a |
Changes only the access time |
-m |
Changes only the modification time |
-t |
Specifies a timestamp (in format |
-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