Following steps are required to write shell script:
(1) Use any editor like vim or mcedit to write shell script.
(2) After writing shell script set execute permission for your script as follows
syntax:
chmod permission your-script-name
Examples:$ chmod +x your-script-name
$ chmod 755 your-script-name
ftp_site="192.168.2.130"
username=user
passwd=password
ftp -in <
open $ftp_site
user $username $passwd
bin
put test >> For testing I have put the test file into ftp server
close
bye
EOF
Edit the crontab for schedule
Crontab -e
# m h dom mon dow command
45 16 * * * ./ftpupload
For every day evening 4.45 pm
Backup
ftp_site=ftp://ftpyoursite.com
username=user
passwd=password
backupdir=$HOME
filename="backup-$(date '+%F-%H%M').tar.gz"
echo "Creating a backup file $filename of $backupdir."
# Make a tar gzipped backup file
tar -cvzf "$filename" "$backupdir"
ftp -in << face="georgia">open $ftp_site
user $username $passwd
bin
put $filename
close
bye
EOF
0 comments:
Post a Comment