Link to home
Start Free TrialLog in
Avatar of JustinBMak
JustinBMak

asked on

Synology Linux Based Cron Job - FTP Connect, Move & Email

Folks:

I'm a windows guru, however I have a small Synology NAS that runs some spreadsheet orders (*.xls format only) and I would like to set up a cron job that run, checks a specific folder (/volume1/TS-Orders) and looks for only a *.xls file and move the file via FTP to a Windows FTP Server that I connect to via anonymous and then e-mail me if it can or cannot process the file.

I have found a few topics here on EE however, nothing seems to work closed where you use a cron - I could be not searching for the right wording.

Here is a link I would like to do: <code>https://www.experts-exchange.com/questions/25093871/Scripting-with-e-mails-and-errors-and-some-logic.html</code> for the e-mail if I understand it correctly.

Any help is appreciated!!
Avatar of AlexPace
AlexPace
Flag of United States of America image

Robo-FTP is a scriptable FTP client for Windows that can do CRON commands... the CRON command basically acts as a "sleep until X time" statement in the Robo-FTP scripting language.  I have used this to make FTP automation logic run, for example, every 15 minutes starting at 6am but only on week days.  You could do the same with a windows Scheduled Task but I preferred to do it all within the script and just leave the script running and sleeping when it wasn't transferring files.
Avatar of JustinBMak
JustinBMak

ASKER

I understand, however this software seems to be for Microsoft Windows.

I am running a Synology (Linux) based NAS and people will be dropping off spreadsheets and I need them to be FTP to a Windows Server via Anonymous login/password. The FTP Service is block by IP and the hosting facility just unblocked my secondary WAN IP.

This Windows Server that I do not have any access to other than via FTP.

Thank you for the reply, however I do not see this working for me.
Avatar of skullnobrains
as simple as it get get with a one-liner

wput /volume1/TS-Orders/*.xls ftp://server/path/to/destination 2>&1 | mail -s yoursubject you@yourdomain.com

if you don't have wput, you can use "curl" or "ftp" or install any of these.

it is setup to send the whole output of the wput command by mail
if you need something more specific, try something along these lines

filelist=$(ls /volume1/TS-Orders/*.xls) || exit 0
for file in $filelist
do if wput "$file" ftp://...
  then mail -s "file $file was transferred successfully" you@yourdomain.com
    rm "$file"
  else mail -s "failed to transfer file $file" you@yourdomain.com
  fi
done

Open in new window


this will not send a mail if there is no xls in the source dir
it will send a simpler email
it will remove xls files that have been sent successfully

adapt to your needs and feel free to post if you need further help
In order to create a script on the Synology (or Linux) to save and tested what you posted above, where do I save the file and what should the file extension be?

Sorry for such a late response, we had an addition to our family and have been a little busy with that if you know what I mean.
ASKER CERTIFIED SOLUTION
Avatar of skullnobrains
skullnobrains

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial