settime Command

Purpose

Updates access and modification times of a file.

Syntax

settime [ [ MMddhhmm[yy ] ] | [ -f ReferenceFile ] ] File ...

Description

settime updates the argument files with the current access and modification times by default. The file is not created if it does not exist. The settime command silently continues its operation if the file does not exist.

Note: Any dates beyond and including the year 2038 are not valid for the settime command.

Flags

Item Description
-f ReferenceFile Use the corresponding time of ReferenceFile instead of the current time.

Parameters

Item Description
MMddhhmm[yy] Time is specified for the settime command in the format MMddhhmm or MMddhhmmyy, where MM is a two-digit representation of the month, dd is a two-digit representation of the day of the month, hh is a two-digit representation of the hour, mm is a two-digit representation of the minute, and yy is a two-digit representation of the year.
File Specifies the name of a file or a space separated list of files.

Exit Status

0
The command completed successfully.
>0
An error occurred.

The return code from settime is the number of specified files for which the times could not be successfully modified.

Examples

  1. To update the access and modification times of the file "infile" to the current time, enter:
    settime infile 
  2. To update the access and modification times of "infile" to be the same as "reffile", enter:
    settime -f reffile infile
  3. To update the access and modification times of multiple files, enter:
    settime file1 file2 file3 
  4. To update the access and modification times of a file to April 9th 2002 with time 23:59, enter:
    settime 0409235902 infile

Files

Item Description
/usr/bin/settime Contains the settime command.