Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following problem. I have a bash script that uses wget to get a few files from the build server, and then scp's them over to the production system: Here is the relevant snippet:

#Several of these lines
wget -nv -O "http://buildserver:8111/guestAuth/repository/download/bt6/.lastFinished/"

#files in the for loop left out for simplicity
for upload_file in ""; do

    scp -B -i /root/$keyfile  $upload_file $user@gateway:/home/$user/deploy_staging
    touch $upload_file

Even with the touch in there the time shown in ls -l of the directory is the time the file was first created. If I do the wget outside the bash script or the touch outside the bash script, the time updates correctly.

What could the issue be?

share|improve this question
I assume the account has write permissions on the file.. – Grizly Sep 3 '10 at 5:28
Yes, it is run as root. – Yishai Sep 7 '10 at 18:34

Using the bellow command it is supose to set the timestamp of the file to your system current datetime:

touch -t `date +%y%m%d%H%M.%S` /path/to/filename

You could try it instead of the plain touch command alone.

Also when you run your bash script run with:

bash -xv your_bash_script.bash

also try using the full path of your commands, to verify the full path of the command do:

whereis touch

Since you could be using this without a shell enviroment using the full path is more recommended to make sure it will run every command without problems.

share|improve this answer

perhaps /bin/touch -m $upload_file is better suited, as it changes the modification time to the current time.

share|improve this answer

Is the file being properly scp'ed? (I can't comment on your question post)

If not, then I think you're missing something to the uploaded file path within the for loop for both commands. Prix points out the way to check the actual commands.

share|improve this answer
Yes, oddly the file does correctly copy. – Yishai Sep 7 '10 at 18:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.