ftp move files every night
Clash 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?
bash shell-script backup
add a comment |Â
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?
bash shell-script backup
What FTP server are you using, and what Unix?
â Kusalananda
Jun 14 at 10:28
add a comment |Â
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?
bash shell-script backup
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?
bash shell-script backup
asked Jun 14 at 6:21
john
516
516
What FTP server are you using, and what Unix?
â Kusalananda
Jun 14 at 10:28
add a comment |Â
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
add a comment |Â
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 * * *
It is not clear from the question whether the user has access to GNUdate
, 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
add a comment |Â
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 * * *
It is not clear from the question whether the user has access to GNUdate
, 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
add a comment |Â
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 * * *
It is not clear from the question whether the user has access to GNUdate
, 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
add a comment |Â
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 * * *
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 * * *
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 GNUdate
, 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
add a comment |Â
It is not clear from the question whether the user has access to GNUdate
, 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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
What FTP server are you using, and what Unix?
â Kusalananda
Jun 14 at 10:28