ftp move files every night

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












i have a FTP in a LAN that all day users upload content.
This gets bulky and messy due to the large amount of files.
Every day i create a new folder with the date and then move all the files from this day, so it can be categorised based on date.
i would like to automate it and make a script to run every night at 12:01



  • create a folder with the previous date

  • move all files from the particular day to tha folder

up to now i have found but i do not know how to create the folder based on date and then move all this files to that particular folder.
some help please?







share|improve this question



















  • What FTP server are you using, and what Unix?
    – Kusalananda
    Jun 14 at 10:28















up vote
-1
down vote

favorite












i have a FTP in a LAN that all day users upload content.
This gets bulky and messy due to the large amount of files.
Every day i create a new folder with the date and then move all the files from this day, so it can be categorised based on date.
i would like to automate it and make a script to run every night at 12:01



  • create a folder with the previous date

  • move all files from the particular day to tha folder

up to now i have found but i do not know how to create the folder based on date and then move all this files to that particular folder.
some help please?







share|improve this question



















  • What FTP server are you using, and what Unix?
    – Kusalananda
    Jun 14 at 10:28













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











i have a FTP in a LAN that all day users upload content.
This gets bulky and messy due to the large amount of files.
Every day i create a new folder with the date and then move all the files from this day, so it can be categorised based on date.
i would like to automate it and make a script to run every night at 12:01



  • create a folder with the previous date

  • move all files from the particular day to tha folder

up to now i have found but i do not know how to create the folder based on date and then move all this files to that particular folder.
some help please?







share|improve this question











i have a FTP in a LAN that all day users upload content.
This gets bulky and messy due to the large amount of files.
Every day i create a new folder with the date and then move all the files from this day, so it can be categorised based on date.
i would like to automate it and make a script to run every night at 12:01



  • create a folder with the previous date

  • move all files from the particular day to tha folder

up to now i have found but i do not know how to create the folder based on date and then move all this files to that particular folder.
some help please?









share|improve this question










share|improve this question




share|improve this question









asked Jun 14 at 6:21









john

516




516











  • What FTP server are you using, and what Unix?
    – Kusalananda
    Jun 14 at 10:28

















  • What FTP server are you using, and what Unix?
    – Kusalananda
    Jun 14 at 10:28
















What FTP server are you using, and what Unix?
– Kusalananda
Jun 14 at 10:28





What FTP server are you using, and what Unix?
– Kusalananda
Jun 14 at 10:28











1 Answer
1






active

oldest

votes

















up vote
0
down vote













You can write a bash script and add it to daily crontab.



YOUR_DIR=/your/dir #All of files in here
YOUR_DEST_DIR=/your/dest #
YESTERDAY=`date +"%F" -d '1 days ago'`
mkdir -p $YOUR_DEST_DIR/$YESTERDAY
mv $YOUR_DIR/* $YOUR_DEST_DIR/$YESTERDAY # move all files in your dir to dest folder with "based on previous date"


Add it to your crontab with every night ad 00:01



1 0 * * *






share|improve this answer























  • It is not clear from the question whether the user has access to GNU date, and it's not clear from your answer what the current directory is supposed to be (where * is expanded).
    – Kusalananda
    Jun 14 at 10:19










  • What would happen with files that are in the process of being transferred (especially if $YOUR_DIR is on another filesystem)?
    – Kusalananda
    Jun 14 at 10:28










  • @Kusalananda thanks
    – nhanpt
    Jun 15 at 2:27










  • the solution is for 2 different setups. One setup has a Debian 9 and the other Ubuntu 16. Both run proftp software. Both are getting correct date and time from ntp. The working directory is in /home/userA/ftp/ and the script will be run as root.
    – john
    Jun 15 at 9:42










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449733%2fftp-move-files-every-night%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You can write a bash script and add it to daily crontab.



YOUR_DIR=/your/dir #All of files in here
YOUR_DEST_DIR=/your/dest #
YESTERDAY=`date +"%F" -d '1 days ago'`
mkdir -p $YOUR_DEST_DIR/$YESTERDAY
mv $YOUR_DIR/* $YOUR_DEST_DIR/$YESTERDAY # move all files in your dir to dest folder with "based on previous date"


Add it to your crontab with every night ad 00:01



1 0 * * *






share|improve this answer























  • It is not clear from the question whether the user has access to GNU date, and it's not clear from your answer what the current directory is supposed to be (where * is expanded).
    – Kusalananda
    Jun 14 at 10:19










  • What would happen with files that are in the process of being transferred (especially if $YOUR_DIR is on another filesystem)?
    – Kusalananda
    Jun 14 at 10:28










  • @Kusalananda thanks
    – nhanpt
    Jun 15 at 2:27










  • the solution is for 2 different setups. One setup has a Debian 9 and the other Ubuntu 16. Both run proftp software. Both are getting correct date and time from ntp. The working directory is in /home/userA/ftp/ and the script will be run as root.
    – john
    Jun 15 at 9:42














up vote
0
down vote













You can write a bash script and add it to daily crontab.



YOUR_DIR=/your/dir #All of files in here
YOUR_DEST_DIR=/your/dest #
YESTERDAY=`date +"%F" -d '1 days ago'`
mkdir -p $YOUR_DEST_DIR/$YESTERDAY
mv $YOUR_DIR/* $YOUR_DEST_DIR/$YESTERDAY # move all files in your dir to dest folder with "based on previous date"


Add it to your crontab with every night ad 00:01



1 0 * * *






share|improve this answer























  • It is not clear from the question whether the user has access to GNU date, and it's not clear from your answer what the current directory is supposed to be (where * is expanded).
    – Kusalananda
    Jun 14 at 10:19










  • What would happen with files that are in the process of being transferred (especially if $YOUR_DIR is on another filesystem)?
    – Kusalananda
    Jun 14 at 10:28










  • @Kusalananda thanks
    – nhanpt
    Jun 15 at 2:27










  • the solution is for 2 different setups. One setup has a Debian 9 and the other Ubuntu 16. Both run proftp software. Both are getting correct date and time from ntp. The working directory is in /home/userA/ftp/ and the script will be run as root.
    – john
    Jun 15 at 9:42












up vote
0
down vote










up vote
0
down vote









You can write a bash script and add it to daily crontab.



YOUR_DIR=/your/dir #All of files in here
YOUR_DEST_DIR=/your/dest #
YESTERDAY=`date +"%F" -d '1 days ago'`
mkdir -p $YOUR_DEST_DIR/$YESTERDAY
mv $YOUR_DIR/* $YOUR_DEST_DIR/$YESTERDAY # move all files in your dir to dest folder with "based on previous date"


Add it to your crontab with every night ad 00:01



1 0 * * *






share|improve this answer















You can write a bash script and add it to daily crontab.



YOUR_DIR=/your/dir #All of files in here
YOUR_DEST_DIR=/your/dest #
YESTERDAY=`date +"%F" -d '1 days ago'`
mkdir -p $YOUR_DEST_DIR/$YESTERDAY
mv $YOUR_DIR/* $YOUR_DEST_DIR/$YESTERDAY # move all files in your dir to dest folder with "based on previous date"


Add it to your crontab with every night ad 00:01



1 0 * * *







share|improve this answer















share|improve this answer



share|improve this answer








edited Jun 15 at 2:34


























answered Jun 14 at 9:59









nhanpt

11




11











  • It is not clear from the question whether the user has access to GNU date, and it's not clear from your answer what the current directory is supposed to be (where * is expanded).
    – Kusalananda
    Jun 14 at 10:19










  • What would happen with files that are in the process of being transferred (especially if $YOUR_DIR is on another filesystem)?
    – Kusalananda
    Jun 14 at 10:28










  • @Kusalananda thanks
    – nhanpt
    Jun 15 at 2:27










  • the solution is for 2 different setups. One setup has a Debian 9 and the other Ubuntu 16. Both run proftp software. Both are getting correct date and time from ntp. The working directory is in /home/userA/ftp/ and the script will be run as root.
    – john
    Jun 15 at 9:42
















  • It is not clear from the question whether the user has access to GNU date, and it's not clear from your answer what the current directory is supposed to be (where * is expanded).
    – Kusalananda
    Jun 14 at 10:19










  • What would happen with files that are in the process of being transferred (especially if $YOUR_DIR is on another filesystem)?
    – Kusalananda
    Jun 14 at 10:28










  • @Kusalananda thanks
    – nhanpt
    Jun 15 at 2:27










  • the solution is for 2 different setups. One setup has a Debian 9 and the other Ubuntu 16. Both run proftp software. Both are getting correct date and time from ntp. The working directory is in /home/userA/ftp/ and the script will be run as root.
    – john
    Jun 15 at 9:42















It is not clear from the question whether the user has access to GNU date, and it's not clear from your answer what the current directory is supposed to be (where * is expanded).
– Kusalananda
Jun 14 at 10:19




It is not clear from the question whether the user has access to GNU date, and it's not clear from your answer what the current directory is supposed to be (where * is expanded).
– Kusalananda
Jun 14 at 10:19












What would happen with files that are in the process of being transferred (especially if $YOUR_DIR is on another filesystem)?
– Kusalananda
Jun 14 at 10:28




What would happen with files that are in the process of being transferred (especially if $YOUR_DIR is on another filesystem)?
– Kusalananda
Jun 14 at 10:28












@Kusalananda thanks
– nhanpt
Jun 15 at 2:27




@Kusalananda thanks
– nhanpt
Jun 15 at 2:27












the solution is for 2 different setups. One setup has a Debian 9 and the other Ubuntu 16. Both run proftp software. Both are getting correct date and time from ntp. The working directory is in /home/userA/ftp/ and the script will be run as root.
– john
Jun 15 at 9:42




the solution is for 2 different setups. One setup has a Debian 9 and the other Ubuntu 16. Both run proftp software. Both are getting correct date and time from ntp. The working directory is in /home/userA/ftp/ and the script will be run as root.
– john
Jun 15 at 9:42












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449733%2fftp-move-files-every-night%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay