亲爱的,
我想在linux crowntab中创建一个日程安排工作,将文件从FTP目录移动(剪切)到本地目录。这不是一次,应该每秒都这样做而不停止。 非常感谢你们。
答案 0 :(得分:0)
你可以做一个循环,用crontab你不能这样做,因为你每分钟都只能开它。您可以尝试的另一个选项是执行60个crontabs并执行此操作
JavaScript critical error at line 1, column 1 in about:Calculator/test.js\n\nSCRIPT1002: Syntax error
你可以做的另一件事是
* * * * * sh path/to/your/script
* * * * * sleep 1 && sh path/to/your/script
* * * * * sleep 2 && sh path/to/your/script
* * * * * sleep 2 && sh path/to/your/script
.
.
.
* * * * * sleep 59 && sh path/to/your/script
此方法必须在每次重启时启动轮询器。
让我们假设您的脚本名为ftp_poller.sh,并将其放在您的主脚本文件夹中,我们可以调用它(/home/fitipaldi/scripts/ftp_poller.sh)
ftp_poller.sh内容
while true;
do sh path/to/your/script &
sleep 1
done
你可以这样做:
#/bin/bash
file=filename
server="example.com"
folder="where_is_the_file" #If it's in the root folder type /
user="username"
pass="supersecretpassword"
/usr/bin/ftp -n << EOF
open ${server}
user ${user} ${pass}
binary
cd ${folder}
get ${file}
del ${file}
EOF
好的,这是INSANE,我不建议您使用此解决方案
但你有另一个解决方案,我认为好多了
* * * * * sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 1 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 2 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 3 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 4 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 5 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 6 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 7 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 8 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 9 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 10 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 11 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 12 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 13 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 14 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 15 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 16 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 17 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 18 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 19 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 20 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 21 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 22 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 23 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 24 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 25 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 26 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 27 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 28 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 29 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 30 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 31 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 32 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 33 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 34 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 35 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 36 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 37 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 38 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 39 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 40 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 41 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 42 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 43 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 44 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 45 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 46 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 47 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 48 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 49 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 50 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 51 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 52 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 53 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 54 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 55 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 56 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 57 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 58 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 59 && sh /home/fitipaldi/scripts/ftp_poller.sh
此方法将触发ftp_poller.sh脚本,完成后将等待1秒并再次触发。
如果您不关心这些流程是否需要1秒钟以上,并且您希望大量流程执行相同操作
while true;
do sh /home/fitipaldi/scripts/ftp_poller.sh
sleep 1
done
此方法将触发ftp_poller.sh脚本并将其置于后台,然后将休眠1秒钟并再次无限启动。