Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8819049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:15:21+00:00 2026-06-14T05:15:21+00:00

I am trying to move a file between directories on the same filesystem. The

  • 0

I am trying to move a file between directories on the same filesystem. The difficulty I am having is that when I use rename() the file access time is changed for that file on the filesystem.

I tried using shell_exec() with mv, though for some reason when I call mv in this way it copies the file and then deletes the original which takes much longer.

Is there any way to move the file quickly without changing the access time? Or can I change it back after calling rename()?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:15:22+00:00Added an answer on June 14, 2026 at 5:15 am

    As a general rule the access time from a file must be changed when a function like rename(), or any other function that access a file, do it.

    As for changing the access time of a file. This is only possible using the touch function, like described in the manual:

    bool touch ( string $filename [, int $time = time() [, int $atime ]] )
    

    Attempts to set the access and modification times of the file named in the filename parameter to the value given in time. Note that the access time is always modified, regardless of the number of parameters.

    As you can see the time parameter is described in the manual as:

    touch time
    

    If time is not supplied, the current system time is used.

    And here is an example from the same page of setting the access time one hour back from a file:

    <?php
        // This is the touch time, we'll set it to one hour in the past.
        $time = time() - 3600;
    
        // Touch the file
        if (!touch('some_file.txt', $time)) {
            echo 'Whoops, something went wrong...';
        } else {
            echo 'Touched file with success';
        }
    ?>
    

    However, be aware that the touch function, as described, attempts to change the file. If you have no permission for example the function will return false. (and won’t change the file time)

    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to move a file but I want to ensure that it exists
I'm trying to map alt left/right to move the cursor focus between the file
I am trying to move from MySQL to MySQLi but am having some problems.
I'm trying to move an app file in OS X using the FileInputStream's transferTo
trying to make an AppleScript droplet that moves a file to a given folder
Im trying to perform a file upload and am having truble generating a route
I'm trying to move a lot of code backwards and forwards between the VS10,
I am trying to move an uploaded file onto a remote server, this isn't
Quick question I am trying to move an uploaded file to a directory outside
I am trying to move a single file (call it foo.txt) from one repository

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.