How to use Shell script to realize automatic upload and download of ftp under Linux
Editor to share with you how to use Shell scripts under Linux to achieve automatic upload and download of ftp. I hope you will get something after reading this article. Let's discuss it together.
1. Ftp automatically logs in to download files in bulk.
The code is as follows:
# from / home/data on ftp server to local / home/databackup####
#! / bin/bash
Ftp-N2. Ftp automatically logs in to upload files.
The code is as follows:
# / home/data#### on the local / home/databackup to ftp server
#! / bin/bash
Ftp-n3. Ftp automatically logs in to download a single file.
The code is as follows:
# download / home/data/a.sh to local / home/databackup#### from ftp server
#! / bin/bash
Ftp-N4. Ftp automatically logs in to upload a single file.
The code is as follows:
# put the local / home/databachup/a.sh up ftp / home/databackup under #
#! / bin/bash
Summary of ftp-n: by saving the above script as a file and adding it to crontab, ftp can automatically upload and download files.
Notes:
1.-n is not affected by .netrc files. (ftp defaults to reading settings in .netrc files)
two。