5.1.【ftp定时下载-练习脚本】
编辑ftp自动执行脚本/test/ftp_auto
open 192.168.1.250
user test 123
lcd /download
binary
prompt
mget *
bye
#!/bin/bash
##filename:ftp_auto
open 192.168.1.250
user test 123
lcd /download
binary
prompt
mget *
bye
5.2.【ftp定时下载-把脚本添加到定时任务内】
执行crontab编写计划任务
• 0 12 * * 1-5 ftp –n < /test/ftp_auto >/dev/null 2> /var/log/ftp_auto_errorlog
0 12 * * 1-5 ftp –n < /test/ftp_auto >/dev/null 2> /var/log/ftp_auto_errorlog
可以使用以下命令查看定时任务 crontab -l
可以使用以下命令编辑定时任务 crontab -e
定时任务指定格式
# Example of job definition: # * * * * * user-name command to be executed # .---------------- minute (0 - 59) //分钟 # | .------------- hour (0 - 23) //代表小时 # | | .---------- day of month (1 - 31) //代表日、天 # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... //代表月份 # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat //代表星期,星期几 # | | | | | # * * * * * user-name command to be executed 例如:30 3,12 * * * /old.sh 每天凌晨3点半和中午12点半的时刻执行/old.sh脚本
------------------------------------------------------------------