0

I am looking for a specific command/script for a cron job I want to perform.

Basically, I have a WordPress website that when you fill in a form writes a png file to a folder. usually with a name like 5d5bb3f4cdcad3.49988477.png.

Basically what I want to do is when a new file is detected in the folder ftp that file to an ftp server. Or preferably email the file, the server does run cPanel so I actually don't know if there is a command function for emailing.

I am used to working with powershell so linux is not my mother-tongue.

slhck
  • 235,242

2 Answers2

0

In your case, I don't think cron on its own is going to be useful for you.

You might want to look at a tool called rsync. It can be set up to look for new files in a location and then move these. You can even move the files across ssh to another server using

rsync -v --ignore-existing -e ssh /home/localuser/ remoteuser@X.X.X.X:/home

I would then schedule a cron job to run every minute/5 minutes to call this function to copy the files where you need.

For more information on rsync, you can use the man rsync command on linux, but there are lots of great tutorials online for rsync which might be easier to get to grips with.

Randomhero
  • 1,543
0

Although I didn't find a direct solution to my problem I found an alternative.

My problem was when the files where being written it was generating a link that would send via email and the link wasn't being called in PHP properly and you couldn't display the file in your web browser. That is why I needed to send it through ftp or email the file.

I found an alternative, I was using a form plugin and it was generating signature image files, I found a function of the plugin to generate a PDF file with all the details and it works properly.

Case closed I guess lol.