Dears ,
i want to make a schedule job in linux crowntab ,to moving (cut) files from a FTP directory to a local directory .it's not one time and should be do this every second without stopping . thanks you all very much in advance .
Dears ,
i want to make a schedule job in linux crowntab ,to moving (cut) files from a FTP directory to a local directory .it's not one time and should be do this every second without stopping . thanks you all very much in advance .
You can do a loop, with crontab you can't do it because you can only fire it every minute. The other option you can try is do 60 crontabs and do this
* * * * * 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
The other thing you can do is
while true;
do sh path/to/your/script &
sleep 1
done
This method you have to start the poller every reboot.
Lets imagine that your script is called ftp_poller.sh and you have it in your home script folder, lets call it (/home/fitipaldi/scripts/ftp_poller.sh)
ftp_poller.sh content
#/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
you can do this:
* * * * * 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
Ok, this is INSANE and I don't recommend you use this solution
But you have another solution, I think is much better
while true;
do sh /home/fitipaldi/scripts/ftp_poller.sh
sleep 1
done
This method will fire the ftp_poller.sh script, when it finish will wait 1 second and fire it again.
If you dont care if the processes can take more that 1 second and you want a lot of processes doing the same you can do
while true;
do sh /home/fitipaldi/scripts/ftp_poller.sh &
sleep 1
done
This method will fire the ftp_poller.sh script and will put it in background, then will sleep 1 second and fire it again infinitely.