Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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 want to add a cron job that scp a folder to a server with on the server the folder name is in another folder whose folder name is a timestamp like ddmmyy

something like

scp -r <foldername> user@server:path/to/destination/ddmmyyhhmmss

ddmmyyhhmmss: date month year hour min sec

share|improve this question
And what is the problem? Of course your 'path/to/destination' must exist. – Jiri Xichtkniha Feb 8 '13 at 13:49
up vote 2 down vote accepted

You can get the date via the date command which lets you specify a date format via %d, %m, etc. Cron treats % characters as special so you need to escape them. Something like this should copy your file at the top of every hour.

0   *   *   *   *   scp -r <foldername> user@server:path/to/destination/$(date +\%d\%m\%y\%H\%M\%S)
share|improve this answer
Thank you, it works – Noor Feb 8 '13 at 14:16

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.