replace files with cron job

Status
Not open for further replies.

Lewis2002

Dabbler
Joined
Dec 21, 2012
Messages
12
I want to replace files from mnt/storage/backup/*.gz to mnt/storage/backup/<date>/*.gz

<date> is the date from today and is a folder that must be created.

I want to do this by a cron job. Something like mv /mnt/storage/backup/*.gz
/mnt/storage/backup/<date>/*.gz

The question: is this possible and how get I the date of today in the command line.
 

Lewis2002

Dabbler
Joined
Dec 21, 2012
Messages
12
I have now: mv /mnt/storage/backup/*.txt /mnt/storage/backup/# date +"%d-%m-%Y"/*.txt but this doesn’t work. I don’t know nothing about linux. So I don’t know if you may use # date +"%d-%m-%Y" on the command line.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Here's what I think you are looking for:

Code:
set FOLDERDATE=`date '+%d-%m-%Y'`
mkdir /mnt/storage/backup/$FOLDERDATE
mv /mnt/storage/backup/*.txt /mnt/storage/backup/$FOLDERDATE/


Make sure you get all those quotes right. Some are quotes and some are the other thing in the upper left corner of your keyboard(the name escapes me at the moment)

Edit: This thread really should have gone in the Off-Topic area. It's not really related to FreeNAS at all.
 

Lewis2002

Dabbler
Joined
Dec 21, 2012
Messages
12
Yes you right. It's not related to FreeNAS. It May even be closed for me. I have now an idea how it’s works. Thanks
 
Status
Not open for further replies.
Top